Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8507373
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T02:51:12+00:00 2026-06-11T02:51:12+00:00

I have a gridview that contains 2 item template 1-checkbox 2-textbox like this: <asp:GridView

  • 0

I have a gridview that contains 2 item template 1-checkbox 2-textbox like this:

<asp:GridView 
    ID="Warehouse_gv" 
    runat="server" 
    AllowPaging="True" 
    align="center" 
    AllowSorting="True" AutoGenerateColumns="False" 
    DataSourceID="Warehouse_gv_SqlDS"
    onselectedindexchanged="Warehouse_gv_SelectedIndexChanged" 
    Width="230px" PageSize="700">

 <Columns>
    <asp:CommandField ShowDeleteButton="False" ShowEditButton="True" />
    <asp:TemplateField HeaderText="Select">
       <ItemTemplate>
            <asp:CheckBox ID="chkSelect" runat="server" />
      </ItemTemplate>

      <HeaderTemplate>
       <input id="chkAll"  
             önclick="javascript:SelectAllCheckboxes(this);" 
             runat="server" type="checkbox" />
      </HeaderTemplate>
    </asp:TemplateField>

    <asp:BoundField DataField="Line Number" 
                    HeaderText="Line Number" ReadOnly="True" 
                    SortExpression="Line Number" />
    <asp:BoundField DataField="Reference" 
                    HeaderText="Reference" ReadOnly="True" 
                    SortExpression="Reference" />
    <asp:BoundField DataField="QTY" HeaderText="QTY"
                    SortExpression="QTY" />

    <asp:TemplateField HeaderText="EditQTY">
      <ItemTemplate>
          <asp:TextBox ID ="test" runat="server" />
     </ItemTemplate>
     <HeaderTemplate>
          EditQTY
     </HeaderTemplate>
    </asp:TemplateField>
   </Columns>
  <EmptyDataTemplate>
    No data could be find!
  </EmptyDataTemplate>
</asp:GridView>

this grid has 6 column 1-editbutton 2-checkbox(first item template) 3-lineNo 4-reference 5-qty 6-editqty(second item template) .
but when I want to save data from this gridview to another database , for textbox field(EditQTY column) that I put in Item template field data doesn’t transfer this is my code behind:

protected void SAVE_btn_Click(object sender, EventArgs e)
    {
        int C = 0;

        for (int i = 0; i < Warehouse_gv.Rows.Count; i++)
        {
            GridViewRow row = Warehouse_gv.Rows[i];
            bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;

            if (isChecked)
            {
                SqlCommand cmd = new SqlCommand();
                cmd.Connection = new SqlConnection(Class1.CnnStr);
                cmd.CommandText = "insert into WarehousePart values (@Reference,@EditQty)";
                cmd.Connection.Open();
                cmd.Parameters.AddWithValue("@Reference", Warehouse_gv.Rows[i].Cells[3].Text); 
                cmd.Parameters.AddWithValue("@EditQty", Warehouse_gv.Rows[i].Cells[5].Text);
                cmd.ExecuteNonQuery();
                cmd.Connection.Close();
                C = C + 1;
            }
        }
    }.
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T02:51:14+00:00Added an answer on June 11, 2026 at 2:51 am

    You have to use FindControl method to obtain the reference of TextBox whose ID is test.

    TextBox test=row.FindControl("test")) as TextBox;
    
    if(test!=null){
      //
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview that contains a CheckBox. <asp:GridView ID=GridView1 runat=server AutoGenerateColumns=false OnRowCreated=GridView1_RowCreated BackColor=#F1EFC5
I have a datalist that contains a gridview inside its itemtemplate. on the item-data_bound
I have a simple GridView ; something like this for a regular Item or
I have a page that contains a GridView with a LinkButton, in a template
I have one grid view that contains some template columns. In this, the first
I have a gridview that contains one linkbutton within itemtemplate. I bind this gridview
So - I have a checkbox <asp:CheckBox ID=chkOrder runat=server Visible='<%#IsCheckBoxVisible() %>' Checked=false OnCheckedChanged=chkOrder_CheckedChanged AutoPostBack=true
I have a gridview that contains user info and one of the columns is
I have a gridview that contains value of every rows read from a text
I have a simple gridview that contains a label in one of the rows.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.