asp.net - How to edit a gridview inside of a modal popup? -
i have gridview appears in modal popup generated dynamically , bound dynamically generated sqldatasource.
i did take advantage of gridview's automatic editing capabilities.
my problem when edit button clicked modalpopup closes due full postback in spite of fact gridview in update panel...
i looked @ solutions here , here neither fixed problem. i've tried every combination under sun regarding positioning of modalpopupextender in relation update panel etc, , have tried changing updatemode conditional well.
markup:
<span class="none"><asp:button id="btndummy" runat="server" text="dummy" /></span> <ajax:modalpopupextender id="mplabel" runat="server" targetcontrolid="btndummy" backgroundcssclass="modalbackground" popupcontrolid="pnllabels"></ajax:modalpopupextender> <asp:panel id="pnllabels" defaultbutton="btnok" style="display:none;" runat="server"> <div style="background-color:#fff;border:1px solid black;padding:7px;"> <asp:updatepanel id="uplabels" runat="server" childrenastriggers="true" enableviewstate="true" updatemode="always"> <contenttemplate> <asp:panel id="pnlgv" runat="server" style="max-height:420px;width:700px;border-bottom:1px #ccc solid;" scrollbars="vertical"> <asp:placeholder id="phlabelinfo" runat="server"></asp:placeholder> <asp:placeholder id="phsds" runat="server"></asp:placeholder> </asp:panel> </contenttemplate> </asp:updatepanel> <asp:button id="btnok" runat="server" text="ok" /> </div> </asp:panel>
code behind:
dim sdslabels new sqldatasource sdslabels.id = "sdslabels" sdslabels.connectionstring = system.configuration.configurationmanager.appsettings.get("generic connection string") sdslabels.providername = "system.data.sqlclient" sdslabels.deletecommand = "delete [js_labels] [labelid] = @labelid" sdslabels.selectcommand = "select [labelid], [circuitnumber], [panelnumber], [additional1], [additional2], [additional3] [js_labels] [quoteitemid] = @quoteitemid" sdslabels.updatecommand = "update [js_labels] set [circuitnumber] = @circuitnumber, [panelnumber] = @panelnumber, [additional1] = @additional1, [additional2] = @additional2, [additional3] = @additional3 [labelid] = @labelid" sdslabels.selectparameters.add(new parameter("quoteitemid", data.dbtype.int32, e.commandargument.tostring())) sdslabels.deleteparameters.add(new parameter("labelid", data.dbtype.int32)) dim paramcollection new parametercollection paramcollection.add("circuitnumber", data.dbtype.string, "") paramcollection.add("panelnumber", data.dbtype.string, "") paramcollection.add("additional1", data.dbtype.string, "") paramcollection.add("additional2", data.dbtype.string, "") paramcollection.add("additional3", data.dbtype.string, "") paramcollection.add("labelid", data.dbtype.int32, "0") dim ph new placeholder ph = ctype(pagehelper.recursivefindcontrol(page, "phsds"), placeholder) ph.controls.add(sdslabels) dim gv new gridview ph = ctype(pagehelper.recursivefindcontrol(page, "phlabelinfo"), placeholder) ph.controls.add(gv) gv.cssclass = "labelstable" dim labelid() string = {"labelid"} gv.datakeynames = labelid gv.enableviewstate = true gv.autogenerateeditbutton = true addhandler gv.rowcommand, addressof gv_rowcommand gv.datasourceid = sdslabels.id gv.databind() mplabel.show()
in experiences, modalpopupextender close on postback unless explicitly ask not in event triggered postback:
btnsubmitrequest_modalpopupextender.show();
Comments
Post a Comment