c# - Button inside modalpopup doesn't execute a line of code for outside component -
problems encountered:
- button inside updatepanel, inside modalpopup, won't execute
.databind() - button executes other codes not
.databind()
what want work:
- when button in modalpopup clicked,
.databind()executed, button inside udatepanel , gridview outside updatpanel
i have 3 updatepanels, execute modalpopupextender separately based on conditions. have gridview, custom button open first popup, outside of 3 updatepanels. 2 updatepanels has button executing .databind() gridview , @ same time hiding other popups. after buttonclick inside popup (this inside updatepanel), previous popup closes means executes code .hide() in codebehind, .databind() did not though put .databind() before .hide()
i tried refresh page using response.redirect , servertransfer instead of using .databind(), , button stopped working. tried surround gridview inside updatepanel use .update when execute button popup, refuses close , second popup appeared making nested popups, button second popup stopped working.
the code works fine thing doesn't work refresh gridview after buttonclick inside popup. if click button popup again (custom button inside gridview), that's when gridview updates, , wrong.
i ran out of ideas how work around this, suggestions this??
html
<asp:gridview id="gridview" runat="server" cssclass="table table-hover" autogeneratecolumns="false" datakeynames="outgoingid" datasourceid="sqldatamaterials" horizontalalign="center" onrowcommand="gridview_rowcommand" width="100%"> <columns> <asp:templatefield headertext="#"> <itemtemplate> <asp:button id="mybutton" runat="server" text="view" commandname="clickme" commandargument='<%# eval("outgoingid") %>' causesvalidation="false" /> </itemtemplate> </asp:templatefield> <asp:boundfield datafield="classificationname" headertext="classificationname" sortexpression="classificationname" /> <asp:boundfield datafield="materialname" headertext="materialname" sortexpression="materialname" /> <asp:boundfield datafield="qty" headertext="qty" sortexpression="qty" /> <asp:boundfield datafield="total" headertext="total" sortexpression="total" /> <asp:boundfield datafield="requestdate" headertext="requestdate" sortexpression="requestdate" /> </columns> <emptydatatemplate> <asp:panel id="panel3" runat="server" cssclass="breadcrumb"> no requests project. </asp:panel> </emptydatatemplate> </asp:gridview> first popup
<asp:panel id="panel2" runat="server" height="400" width="700" class="modalpopup"> <section class=" text-center" style="height: 149px; padding: 2px; vertical-align: middle; text-align: center;"> <section class="label-info"> <asp:button id="btn_close" runat="server" text="close" width="50px" height="20px" cssclass="btn-danger pull-right" font-size="smaller" /> <asp:label id="label1" runat="server" text="request information" cssclass="label"> </asp:label> </section> <asp:updatepanel id="updatepanel1" runat="server"> <contenttemplate> (some long html here buttons execute other popups) </contenttemplate> </asp:updatepanel> </section> </asp:panel> <asp:hiddenfield id="hiddenfield1" runat="server" /> <ajaxtoolkit:modalpopupextender id="modalpopupextender1" runat="server" behaviorid="popup" popupcontrolid="panel2" dropshadow="true" backgroundcssclass="modalbackground" targetcontrolid="hiddenfield1" okcontrolid="btn_close"> <animations> <onshown><fadein duration="0.50" /></onshown> <onhiding><fadeout duration=".05" /></onhiding> </animations> </ajaxtoolkit:modalpopupextender> second popup
<asp:updatepanel id="updatepanel2" runat="server" updatemode="conditional"> <contenttemplate> <asp:hiddenfield id="hiddenfield2" runat="server" /> <asp:panel id="panelsuccess" runat="server" height="150" width="300" class="modalpopup"> <section class="text-center"> <h5>request approved.</h5> <br /> <asp:button id="btnsuccessok" runat="server" text="ok" cssclass="btn btn-sm btn-success" onclick="btnsuccessok_click" /> </section> </asp:panel> <ajaxtoolkit:modalpopupextender id="modalalertsuccess" runat="server" behaviorid="popup2" popupcontrolid="panelsuccess" dropshadow="true" targetcontrolid="hiddenfield2" backgroundcssclass="modalbackground" okcontrolid="btnsuccessok"> <animations> <onshown><fadein duration="0.50" /></onshown> <onhiding><fadeout duration=".05" /></onhiding> </animations> </ajaxtoolkit:modalpopupextender> </contenttemplate> <triggers> <asp:postbacktrigger controlid="btnsuccessok" /> </triggers> </asp:updatepanel> third popup
<asp:updatepanel id="updatepanel3" runat="server" updatemode="conditional"> <contenttemplate> <asp:hiddenfield id="hiddenfield3" runat="server" /> <asp:panel id="panelcancel" runat="server" height="150" width="300" class="modalpopup"> <section class="text-center"> <h5>request cancelled.</h5> <br /> <asp:button id="btncancelrq" runat="server" text="ok" cssclass="btn btn-sm btn-success" onclick="btncancelrq_click" /> </section> </asp:panel> <ajaxtoolkit:modalpopupextender id="modalalertcancel" runat="server" behaviorid="popup3" popupcontrolid="panelcancel" dropshadow="true" targetcontrolid="hiddenfield3" backgroundcssclass="modalbackground" okcontrolid="btncancelrq"> <animations> <onshown><fadein duration="0.50" /></onshown> <onhiding><fadeout duration=".05" /></onhiding> </animations> </ajaxtoolkit:modalpopupextender> </contenttemplate> </asp:updatepanel> and the code behind
this first popup
protected void btn_approve_click(object sender, eventargs e) { try { if (hf_outgoingid.value != null) { var abc = (from in db.outgoings a.outgoingid == convert.toint32(hf_outgoingid.value) select a).firstordefault(); abc.status = "approved"; db.submitchanges(); gridview.databind(); modalpopupextender1.hide(); modalalertsuccess.show(); } } catch (exception x) { } } and in case second/third popup
protected void btnsuccessok_click(object sender, eventargs e) { gridview.databind(); } protected void btncancelrq_click(object sender, eventargs e) { gridview.databind(); }
you have assign data source before databind gridview bind data
protected void btnsuccessok_click(object sender, eventargs e) { gridview.datasourceid = sqldatamaterials; gridview.databind(); } protected void btncancelrq_click(object sender, eventargs e) { gridview.datasourceid = sqldatamaterials; gridview.databind(); }
Comments
Post a Comment