Object reference not set to an instance of an object.
Line 74: DTSample.Rows[e.RowIndex]["Column0"] = t1.Text;
the code the given below. please help me
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = Convert.ToInt32(e.NewEditIndex);
HiddenField1.Value = e.NewEditIndex.ToString();
GridView1.DataBind();
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
TextBox t1 = new TextBox();
TextBox t2 = new TextBox();
t1 = (TextBox)GridView1.Rows[Convert.ToInt32(HiddenField1.Value)].Cells[2].Controls[0];
t2 = (TextBox)GridView1.Rows[Convert.ToInt32(HiddenField1.Value)].Cells[3].Controls[0];
DTSample.Rows[e.RowIndex]["roll"] = t1.Text;
DTSample.Rows[e.RowIndex]["name"] = t2.Text;
GridView1.EditIndex = -1;
GridView1.DataBind();
}
VulpesPosted May 28, 2011, 12:48 PM
Could you have added some more rows to the GridView but not updated the DataTable?
Sam HobbsPosted May 29, 2011, 6:33 PM
saifullah khanPosted May 28, 2011, 12:10 PM
VulpesPosted May 28, 2011, 8:41 AM
DTSample.Rows[e.RowIndex][0] = t1.Text;