title: asp.net gridview in update panel, make visible and update content
body: <p>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? </p>
  
  <pre><code>&lt;div class="span-93 prepend-2 top"&gt;
          &lt;strong&gt;Enter  Number&lt;/strong&gt;&lt;br /&gt;
          &lt;asp:TextBox ID="PartNumber" runat="server" Width="100"&gt;&lt;/asp:TextBox&gt;
          &lt;asp:Button ID="CreateButton" runat="server" Width="85" Text="Locate" OnClick="CreateButton_Click" /&gt;
      &lt;/div&gt;
  &lt;asp:Label ID="Select" runat="server" Font-Bold="true" Text="Select choice" Visible="false"&gt;&lt;/asp:Label&gt;&lt;br /&gt;
              &lt;ajax:UpdatePanel ID="UpdatePanel" runat="server" UpdateMode="Conditional"&gt;
                  &lt;ContentTemplate&gt;
                      &lt;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"&gt;
                          &lt;Columns&gt;
                              ...
                          &lt;/Columns&gt;
                      &lt;/asp:GridView&gt;
                  &lt;/ContentTemplate&gt;
                  &lt;Triggers&gt;
                      &lt;ajax:AsyncPostBackTrigger ControlID="CreateButton"/&gt;
                  &lt;/Triggers&gt;
              &lt;/ajax:UpdatePanel&gt;
  </code></pre>
  
  <p>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.</p>
  
  <p>Edit: Binding Code to gridview:</p>
  
  <pre><code>    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();
              }
          }
      }
  </code></pre>