I have and Update Panel with a Grid inside of it. The grid's data will depend on a what a user
inserts into a Search textbox. They will click Search and on clientside the grid slides in via
some Ajax animations i used. My issue is the I want the grid to reload with the text in the
search box as it's parameter data. How do I reload that Grid's Update Panel on click of that
button?
<font color="blue">Search:</font><asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/bttnSearch.gif" Height="19" />
</p>
<div id="moveMe" style="display:">
<div style="float:right;">
<asp:LinkButton ID="lnkBtnCloseColHelp" runat="server" Text="X" OnClientClick="return false;" />
</div>
<br /><br />
<center>
<table>
<tr>
<td>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate >
//Gridview and SqlDatasource goes here.
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID = "ImageButton2" EventName = "Click"/>
</Triggers>
</asp:UpdatePanel>
My Grid won't load because It needs to get that data in the textbox. Should that textbox be inside of the updatepanel also? Any Ideas on how i can get the Grid alone to reload based on the textbox's text after the search button is hit.
Yeah, this is a little vague, so my answer will be as well. You will have to handle the click event of the image button in your code behind. At that point you will need to rebind the gridview with the updated results.
How about 'hacking' this way. Have a dummy hidden textbox or hidden field control within the UpdatePanel. Perform a client-side copy of the actual textbox value to the hidden control when the button is clicked. Not elegant but should work.
Additional Info: If the trigger is set as AsyncPostBack:
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1">
</asp:AsyncPostBackTrigger>
</Triggers>
The postback actually gets the values of all the controls outside the UpdatePanel. So my hack is not required at all.
You can probably put both of those sections in different update panels.
You can have one update panel containing the search box input and image button, and another one containing your grid control.