title: Search gridview ItemTemplate textbox value on buttonclick
body: <p>My Scenario is that i had a gridview,i had taken itemtemplate textboxes and a button,when the gridview is loaded the user enters a ServiceCode based on the ServiceCode and on button click,data should be displayed into the gridview,when the data is displaye in the gridview the user enters the quantity and the discount then the result should be displayed in the netamount,i had written the code but it is not working i would appreciate if someone share thier knowledge with me. </p>
  
  <p>My Axpx Code is:</p>
  
  <pre><code>        &lt;asp:GridView ID="GridView1" runat="server" Height="157px" Width="639px"
          AutoGenerateColumns="False" BorderWidth="1px"
          HorizontalAlign="Justify" onrowdatabound="GridView1_RowDataBound"
          BackColor="LightGoldenrodYellow" BorderColor="Tan" CellPadding="2"
          ForeColor="Black" GridLines="None" onrowcommand="GridView1_RowCommand"&gt;
          &lt;FooterStyle BackColor="Tan" /&gt;
          &lt;PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue"
          HorizontalAlign="Center" /&gt;
          &lt;SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" /&gt;
          &lt;HeaderStyle BackColor="#FFFFC4" Font-Bold="True" ForeColor="#BF6000"/&gt;
          &lt;Columns&gt;
          &lt;asp:TemplateField HeaderText="S.No"&gt;
          &lt;ItemTemplate&gt;
          &lt;asp:Label ID="label10" runat="server" Font-Bold="true" ForeColor="#BF6000"        Text="&lt;%# Container.DataItemIndex + 1 %&gt;"&gt;
          &lt;/asp:Label&gt;
          &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Serv Code" &gt;
          &lt;ItemTemplate&gt;
          &lt;asp:TextBox ID="TxtServiceCode" Font-Bold="true" ForeColor="#BF6000" Text='&lt;%#  DataBinder.Eval(Container,"DataItem.ServiceCode") %&gt;'
           runat="server" Width="55px"&gt;
          &lt;/asp:TextBox&gt;
  
          &lt;asp:Button ID="Insert" runat="server" BackColor="Ivory" CommandName="InsertRecord"
          Font-Bold="True" ForeColor="#BF6000" Text="Insert" onclick="Insert_Click"/&gt;
  
           &lt;/ItemTemplate&gt;
             &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Name"&gt;
         &lt;ItemTemplate&gt;
            &lt;asp:TextBox ID="TxtName" runat="server" ReadOnly="true" Font-Bold="true"           ForeColor="#BF6000" Width="150px" Text='&lt;%#  DataBinder.Eval(Container, "DataItem.ServiceName") %&gt;'&gt;&lt;/asp:TextBox&gt;
            &lt;/ItemTemplate&gt;
           &lt;/asp:TemplateField&gt;
            &lt;asp:TemplateField HeaderText="Serv Amt"&gt;
          &lt;ItemTemplate&gt;
          &lt;asp:TextBox ID="TxtServiceAmount" ReadOnly="true" Font-Bold="true" ForeColor="#BF6000" Text='&lt;%# DataBinder.Eval(Container,"DataItem.ServiceAmount") %&gt;'
             runat="server" Width="55px"&gt;&lt;/asp:TextBox&gt;
          &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
           &lt;asp:TemplateField HeaderText="Qty"&gt;
          &lt;ItemTemplate&gt;
            &lt;asp:TextBox ID="TxtQuantity" Font-Bold="true" ForeColor="#BF6000" Text='&lt;%#       DataBinder.Eval(Container,"DataItem.Quantity") %&gt;'
           runat="server" Width="55px"&gt;&lt;/asp:TextBox&gt;
             &lt;/ItemTemplate&gt;
          &lt;/asp:TemplateField&gt;
          &lt;asp:TemplateField HeaderText="Disc Amt"&gt;
          &lt;ItemTemplate&gt;
            &lt;asp:TextBox ID="TxtdiscAmt" Font-Bold="true" ForeColor="#BF6000" Text ='&lt;%# DataBinder.Eval(Container,"DataItem.Discount") %&gt;'
  AutoPostBack="true" OnTextChanged="TxtdiscAmt_TextChanged" runat="server" Width="55px"&gt;                &lt;/asp:TextBox&gt;
               &lt;/ItemTemplate&gt;
              &lt;/asp:TemplateField&gt;
  
              &lt;asp:TemplateField HeaderText="Net Amt"&gt;
              &lt;ItemTemplate&gt;
                 &lt;asp:TextBox ID="lblNet" runat="Server" Font-Bold="true"  ForeColor="#BF6000" Width="55" /&gt;
              &lt;/ItemTemplate&gt;
            &lt;/asp:TemplateField&gt;
           &lt;/Columns&gt;
             &lt;AlternatingRowStyle BackColor="PaleGoldenrod" /&gt;
             &lt;/asp:GridView&gt;
  </code></pre>
  
  <p>MY CS Code is:</p>
  
  <pre><code> DataSet dss = new DataSet();
    SqlConnection MyConnection = new SqlConnection("server=prog;database=mydatabase; UID=sa;PWD=nato123;");
  
     SqlCommand sqlcmd = new SqlCommand("select * from [Bill]", MyConnection);
  
     SqlDataAdapter adp = new SqlDataAdapter(sqlcmd);
     DataSet ds = new DataSet();
      adp.Fill(ds);
  
     GridView1.DataSource = ds.Tables[0];
  
     GridView1.DataBind();
      } 
  </code></pre>