Trigger to refresh DataView when user clicks a button inside an UpdatePanel
我们在UpdatePanel中具有以下代码。
1 2 3 4 5 6 7 8 9 10 11 12 | <asp:UpdatePanel ID="UpdatePanelSearch" runat="server" UpdateMode="Conditional"> <ContentTemplate> <p>Parent Search: </asp:TextBox> </p> </ContentTemplate> </asp:UpdatePanel> |
VB文件中的代码看起来像这样,可以单击"搜索"按钮,因此GridView将基于在TextBox中输入的值来显示数据。
GridView也位于单独的UpdatePanel中:
1 2 3 4 | Protected Sub ButtonSearch_Click(sender As Object, e As EventArgs) Handles ButtonSearch.Click GridViewParentsSummary.DataSource = theTableAdapter.GetData(strSearchText) End Sub |
如果这是正确的操作,我们想创建一个触发器来更新GridView。
这是GridView:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | <ContentTemplate> <asp:GridView ID="GridViewParentsSummary" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" PageSize="3" > <Columns> <asp:BoundField DataField="FatherName" HeaderText="Father's Name" SortExpression="FatherName" /> <asp:BoundField DataField="MotherName" HeaderText="Mother's Name" SortExpression="MotherName" /> <asp:ButtonField ButtonType="Button" CommandName="Select" Text="Select This Parent" /> </Columns> </asp:GridView> </ContentTemplate> </asp:UpdatePanel> |
您能显示执行刷新GridView的正确触发器所需的所需代码吗?
如果
但是,并非总是如此,因此您经常将其更改为
1 | gridUpdatePanel.Update() 'assuming gridUpdatePanel is the UpdatePanel with the grid |
有关
http://msdn.microsoft.com/zh-cn/library/system.web.ui.updatepanel.updatemode.aspx