c# - Using updatepanel with gridview templatefield (ImageButton), Firing event but no changes in forntend -
i using updatepanel templatefield itemtemplate imagebutton control. when imagebutton pressed event behind button fired mend populate textfields not do.
.aspx code:
<asp:templatefield showheader="false"> <itemtemplate> <asp:updatepanel id="updatepanel4" runat="server"> <triggers> <asp:asyncpostbacktrigger controlid="_btnuseredit" eventname="click" /> </triggers> <contenttemplate> <asp:imagebutton id="_btnuseredit" runat="server" imageurl="~/images/edit.png" commandname="" height="30px" width="30px" onclick="_btnuseredit_click" causesvalidation="false" /> </contenttemplate> </asp:updatepanel> </itemtemplate> <itemstyle width="35px" /> </asp:templatefield>
c# code:
protected void _btnuseredit_click(object sender, eventargs e) { using (establishmentdatacontext db = new establishmentdatacontext()) { imagebutton btn = (imagebutton)sender; gridviewrow row = (gridviewrow)btn.namingcontainer; id = convert.toint32(row.cells[0].text); var edit = (from in db.users a.userid == convert.toint32(row.cells[0].text) select a).firstordefault(); _txtname.text = edit.name; _email.text = edit.useremail; _password.text = _txtconfpassword.text = edit.strpassword; } }
for using asyncpostbacktrigger
inside gridview
need add trigger in rowdatabound
event this.
protected void gridview1_rowdatabound(object sender, gridviewroweventargs e) { if(e.row.rowtype == datacontrolrowtype.datarow) { var editbutton = e.row.findcontrol("_btnuseredit") imagebutton; updatepanel1.triggers.add(new asyncpostbacktrigger{ controlid=editbutton.uniqueid, eventname="click"}); } }
Comments
Post a Comment