Object reference not set to an instance of an object.
Code
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();
}

VulpesRank #55 · 29.2K reputationPosted May 28, 2011, 8:48 AM EDT
Could you have added some more rows to the GridView but not updated the DataTable?
VulpesRank #55 · 29.2K reputationPosted May 28, 2011, 4:41 AM EDT
DTSample.Rows[e.RowIndex][0] = t1.Text;
saifullah khanRank #4,887 · 320 reputationPosted May 28, 2011, 8:10 AM EDT
Sam HobbsRank #107 · 20.5K reputationPosted May 29, 2011, 2:33 PM EDT