We have the following code in an UpdatePanel.
<asp:UpdatePanel
ID="UpdatePanelSearch"
runat="server"
UpdateMode="Conditional">
<ContentTemplate>
<p>Parent Search:
<asp:TextBox ID="TextBoxSearch" runat="server" Width="207px"></asp:TextBox>
<asp:Button ID="ButtonSearch" runat="server" Text="Search" />
</p>
</ContentTemplate>
</asp:UpdatePanel>
The code in the VB file looks like this to handle clicking the Search button so a GridView will display data based on the value entered into the TextBox.
The GridView is also in a separate UpdatePanel:
Protected Sub ButtonSearch_Click(sender As Object, e As EventArgs) Handles ButtonSearch.Click
GridViewParentsSummary.DataSource = theTableAdapter.GetData(strSearchText)
End Sub
We would like to create a trigger to update the GridView if that is the correct thing to do here.
Here is the GridView:
<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>
Can you show the needed code required to make the correct trigger that will refresh the GridView?
If the
GridViewis in anotherUpdatePanelit should also update when anotherUpdatePanelupdates. By default, theUpdatePanel.UpdateModeproperty is set toAlwaysand this will cause allUpdatePanelin page to refresh.However, this is not always the desired behavior so many time you’ll change it to
Conditionalwhich means that theUpdatePanelwill be refreshed only if one of its triggers was fired. In that case, you need to add this line in theButtonSearch_Clickmethod:for more information about the
UpdateModeproperty look here:http://msdn.microsoft.com/en-us/library/system.web.ui.updatepanel.updatemode.aspx