c# - RowEditing is fired when update button is clicked in GridView -
i have created gridview
below:
protected void page_load(object sender, eventargs e) { gridview gv = new gridview(); gv.id = pid.tostring(); gv.autogenerateeditbutton = true; gv.datakeynames = ids; gv.rowediting += gv_rowediting; gv.rowupdating += gv_rowupdating; bindgv(pid, gv); }
i have written following methods:-
rowupdating
:
void gv_rowupdating(object sender, gridviewupdateeventargs e) { gridview gv = sender gridview; gridviewrow row = (gridviewrow)gv.rows[e.rowindex]; productcategory pc = context.productcategories.first(s => s.name ==gv.id ); textbox txtname = row.findcontrol("txtname") textbox; pc.name = txtname.text; }
rowediting
:
void gv_rowediting(object sender, gridviewediteventargs e) { gridview gv = sender gridview; gv.editindex = e.neweditindex; bindgv(convert.toint32(gv.id), gv); }
but when ran codes in debugging mode, clicking on update button invokes gv_rowediting
method instead of gv_rowupdating
. problem?
the sequence of firing events of gridview when click on edit button update record calls rowediting event , after when click on update button calls rowupdating event. rowediting event invokes first rowupdating.
Comments
Post a Comment