title: Add data from Textbox to GridView on button click
body: <p>I have 1 Dropdownlist and 3 Textboxes and I want to add data from textboxes and after a button click they will be added to GridView</p>
  
  <pre><code>&lt;asp:DropdownList ID="ddlClassification" runat="server" &gt;
  &lt;asp:ListItem&gt;&lt;/asp:ListItem&gt;
  &lt;asp:ListItem&gt;Sample 1&lt;/asp:ListItem&gt;
  &lt;asp:ListItem&gt;Sample 2&lt;/asp:ListItem&gt;
  &lt;asp:ListItem&gt;Sample 3&lt;/asp:ListItem&gt;
  &lt;/asp:DropdownList&gt;
  
  &lt;asp:TextBox ID="tbCost" runat="server" Width="100" &gt;&lt;/asp:TextBox&gt;
  &lt;asp:TextBox ID="tbAccumulate" runat="server" Width="100" &gt;&lt;/asp:TextBox&gt;
  &lt;asp:TextBox ID="tbNRV" runat="server" Width="100" &gt;&lt;/asp:TextBox&gt;
  
  &lt;asp:Button ID="btnAdd" runat="server" Text="ADD" onclick="btnAdd_Click" /&gt;
  </code></pre>
  
  <p>and this is What I have in code behind</p>
  
  <pre><code>public partial class SetUP : System.Web.UI.Page
  {
      DataRow dr;
      DataTable dt = new DataTable();
      protected void Page_Load(object sender, EventArgs e)
      {
          dt.Columns.Add("Classification");
          dt.Columns.Add("Cost");
          dt.Columns.Add("Accumulate");
          dt.Columns.Add("NRV");
      }
  
      protected void btnAdd_Click(object sender, EventArgs e)
      {
          dr = dt.NewRow();
          dr["Classification"] = ddlClassification.Text;
          dr["Cost"] = tbCost.Text;
          dr["Accumulate"] = tbAccumulate.Text;
          dr["NRV"] = tbNRV.Text;
          dt.Rows.Add(dr);
          GridView1.DataSource = dt;
          GridView1.DataBind();
      }
  </code></pre>
  
  <p>I have done this once but now I am getting error on <code>GridView1.DataBind();</code> can someone help me in my problem</p>