Thursday, 15 July 2010

asp.net - How to update gridview row event args -



asp.net - How to update gridview row event args -

design.apsx[1]

gridview.aspx.cs

protected void gridview1_rowupdating(object sender, gridviewupdateeventargs e) { //retrieve table session object. datatable dt = (datatable)session["sql2008.services"]; //update values. gridviewrow row = gridview1.rows[e.rowindex]; dt.rows[row.dataitemindex]["firstname"] = ((textbox)(row.cells[1].controls[0])).text;//null reference thrown dt.rows[row.dataitemindex]["lastname"] = ((textbox)(row.cells[2].controls[0])).text; dt.rows[row.dataitemindex]["product"] = ((textbox)(row.cells[3].controls[0])).text; dt.rows[row.dataitemindex]["mobile"] = ((textbox)(row.cells[4].controls[0])).text; dt.rows[row.dataitemindex]["city"] = ((textbox)(row.cells[5].controls[0])).text; dt.rows[row.dataitemindex]["store"] = ((textbox)(row.cells[6].controls[0])).text; dt.rows[row.dataitemindex]["details"] = ((textbox)(row.cells[7].controls[0])).text; //reset edit index. gridview1.editindex = -1; //bind info gridview control. bind(); } public void bind() { gridview1.datasource = session["sql2008.services"]; gridview1.databind(); }

when update grid view throws object reference not set instance of object says int gridview.aspx.cs getting mentioned error

asp.net sql gridview databound

No comments:

Post a Comment