Tech
Forums
Jobs
Books
Events
Videos
Live
More
Interviews
Certification
Training
Career
Members
News
Blogs
Contribute
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
4
Answers
Object reference not set to an instance of an object.
saifullah khan
13y
1.8k
1
Reply
i want to edit and update data in grid view but i get he following error.
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();
}
Post
Reset
Cancel
Answers (
4
)
Next Recommended Forum
search in database table
Thread problem