Я пытаюсь установить флажок в gridview,
Работа этого флажка заключается в проверке записи,
Когда нажата эта кнопка проверки, все элементы с отмеченным флажкомвведено в базу данных
Это мой код:
protected void Button1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox cbox = ((CheckBox)row.FindControl("Verify"));
if (cbox.Equals(true))
{
String DraftsText = ((TextBox)row.FindControl("numDrafts")).Text;
String TCtext = ((TextBox)row.FindControl("numTC")).Text;
if (row.RowType == DataControlRowType.DataRow)
{
//Header trs = new Header();
// GridView1.Rows[0].FindControl("numTC");
if (TCtext != "" && DraftsText != "")
{
// try
// {
string date = row.Cells[4].Text;
DateTime dateTime = Convert.ToDateTime(date);
string dateFormatted = dateTime.ToString("d-MMM-yy");
string unit = row.Cells[5].Text;
string currency = row.Cells[6].Text;
string totalFC = row.Cells[7].Text;
string totalDC = row.Cells[8].Text;
int d = Convert.ToInt32(DraftsText);
int tc = Convert.ToInt32(TCtext);
hdr = new Header(d, tc, dateFormatted, unit, currency, totalFC, totalDC);
hdr.InsertFCTC(hdr);
}
}
}
}
}
Возможно, я поступаю неправильно, но в if (cbox.Equals (true)) это дает мне исключение: Ссылка на объект не установлена для экземпляра объекта.
Любая идея, что я могу сделать, чтобы решить эту проблему?
Большое спасибо