vb.net - Refreshing an ASP.Net GridView if an ASP.Net button and the GridView are in different asp:Content blocks -
we refresh asp.net gridview if asp.net button , gridview in different asp:content blocks
in working asp.net web form had datasource, gridview, detailsview, various other controls, asp:textbox , asp:button searching data based on user enters textbox. of these in single asp:content block , had asp:updatepanel.
we decided change layout of form , separate gridview , detailsview , place them asp:content block. when form run, showed in correct locations on screen , showed data database expected.
we discovered if user entered search criteria , clicked search button, code in code-behind file did execute gridview did not refresh.
i'm going assume coding needs added in code-behind file that.
here markup search button 1 of asp:content blocks:
<asp:content id="contentbody" contentplaceholderid="bodyplaceholder" runat="server"> <% '-- ajax enable area flicker cut down minumum. -- %> <% '---------------------------------------------------------------- %> <asp:updatepanel id="updatepanelsummary" runat="server" updatemode="conditional"> <contenttemplate> <h1>classes / subjects maintenance</h1> class search: <asp:textbox id="textboxsearch" runat="server" width="207px" text="all"> </asp:textbox> <asp:button id="buttonsearch" runat="server" text="search" onclick="buttonsearch_click" /> <asp:button id="buttonsearchall" runat="server" text="show classes" onclick="buttonsearchall_click"/> <br /> <asp:button id="buttonaddnewclass" runat="server" text="add new class list" /> <br /> <strong><span class="auto-style1"> <br /> send email of list, enter email address of whom wish send click envelope.</span></strong> <br /> <br /> recipient: <asp:textbox id="textboxemailrecipient" runat="server" width="203px"></asp:textbox> <strong><span class="auto-style1"> </span></strong> <asp:imagebutton id="imagebuttonemailthislist" runat="server" borderstyle="none" imageurl="~/images/email1.png" onclick="imagebuttonemailthislist_click" tooltip="email list report." height="50px" width="50px" /> <br /> <asp:label id="labelemailmessage" runat="server" style="font-weight: 700; color: black"></asp:label> <br /> </contenttemplate> </asp:updatepanel> </asp:content>
this markup of asp:content block has gridview:
<asp:content id="detailsbody" contentplaceholderid="detailsplaceholder" runat="server"> <asp:updatepanel id="updatepaneldetails" runat="server" updatemode="conditional"> <contenttemplate> <% '-- gridview (grid) summary. -- %> <% '-- user chooses class here , details shown in detailsview. -- %> <% '--------------------------------------------------------------------------------- %> <asp:gridview id="gridviewsummary" runat="server" allowsorting="true" autogeneratecolumns="false" datakeynames="id" width="401px" allowpaging="true" pagesize="3"> <columns> <asp:boundfield datafield="classname" headertext="class / subject" sortexpression="classname" > <headerstyle horizontalalign="left" /> <itemstyle horizontalalign="left" /> </asp:boundfield> <asp:boundfield datafield="grade" headertext="grade" sortexpression="grade" > <headerstyle horizontalalign="left" /> <itemstyle horizontalalign="left" /> </asp:boundfield> <asp:commandfield buttontype="button" selecttext="select class details" showselectbutton="true"/> </columns> <pagersettings firstpagetext="first" lastpagetext="last" mode="nextpreviousfirstlast" nextpagetext="next" previouspagetext="previous"/> </asp:gridview> </contenttemplate> </asp:updatepanel> </asp:content>
a lot of controls have been taken out code easier follow.
this coding code-behind file loads data gridview after user clicks search button:
protected sub buttonsearch_click(sender object, e eventargs) ' show schedules user wants. '----------------------------------- gridviewsummary.datasource = thetableadapter.getdatabyallclasses(textboxsearch.text) gridviewsummary.databind() end sub
you can call updatepaneldetails.update()
after bind data on buttonsearch_click
protected sub buttonsearch_click(sender object, e eventargs) ' show schedules user wants. '----------------------------------- gridviewsummary.datasource = thetableadapter.getdatabyallclasses(textboxsearch.text) gridviewsummary.databind() updatepaneldetails.update() end sub
Comments
Post a Comment