Currently, I have a dynamically created gridview on my page. When a user enters something in a textbox and presses a button, the whole page refreshes to populate the gridview and make it visible. I do not want that anymore. How would I go about using the UpdatePanel to make the gridview visible and populate it?
<div class="span-93 prepend-2 top">
<strong>Enter Number</strong><br />
<asp:TextBox ID="PartNumber" runat="server" Width="100"></asp:TextBox>
<asp:Button ID="CreateButton" runat="server" Width="85" Text="Locate" OnClick="CreateButton_Click" />
</div>
<asp:Label ID="Select" runat="server" Font-Bold="true" Text="Select choice" Visible="false"></asp:Label><br />
<ajax:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:GridView ID="GridView" Visible="false" runat="server" HeaderStyle-Width="200" HeaderStyle-BackColor="#2B6292" HeaderStyle-ForeColor="White"
AllowSorting="true" AllowPaging="true" Width="600" AutoGenerateColumns="False" OnRowCreated="GridView_OnRowCreated"
DataKeyNames="Id" onsorting="GridView_OnSort">
<Columns>
...
</Columns>
</asp:GridView>
</ContentTemplate>
<Triggers>
<ajax:AsyncPostBackTrigger ControlID="CreateButton"/>
</Triggers>
</ajax:UpdatePanel>
Theres another button on the page called CreateButton, obviously, that will populate the gridview and make it visible so a user can select from it. Is this possible? Thanks in advance.
Edit: Binding Code to gridview:
protected void Create_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(Number.Text))
{
BLL newbll = new BLL();
Database.DataTable tempTable = newbll.GetItemByPartNumber(Number.Text);
if (Table.Count != 0)
{
DataTable table = tempTable ;
string[] VID = { "Id" };
GridviewDiv.Visible = true;
GridView.DataSource = table;
GridView.DataKeyNames = VID;
GridView.DataBind();
}
}
}