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

  • Home
  • SEARCH
  • 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 3225776
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T16:22:43+00:00 2026-05-17T16:22:43+00:00

in a GridView (ASP.NET/C#), I have a number of template fields – the 2

  • 0

in a GridView (ASP.NET/C#), I have a number of template fields – the 2 ones relevant to the question are ‘checkbox1’ and ‘quantity’. The checkbox starts off as unticked for every row, and the quantity starts off as disabled for every row. But when the user ticks one of the rows checkboxes, I need a piece of JavaScript or something to check if the relevant rows checkbox is checked, and if so enable to the rows quantity textbox.

How do I do this?

  • 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-05-17T16:22:44+00:00Added an answer on May 17, 2026 at 4:22 pm

    Make sure you start with your quantity disabled. I am assuming it is a TextBox:

    <asp:TemplateField>
        <ItemTemplate>
            <asp:CheckBox ID="checkbox1" runat="server" />
        </ItemTemplate>
    </asp:TemplateField>
    <asp:TemplateField>
        <ItemTemplate>
            <asp:TextBox ID="quantity" runat="server" Enabled="false" />
        </ItemTemplate>
    </asp:TemplateField>
    

    Add this piece of javascript on your page:

    <script type="text/javascript">
    
        function ChangeQuantityEnable(id, enable) {
            document.getElementById(id).disabled = !enable;
        }
    
    </script>
    

    Then in the RowDataBound event handler for your gridview, add

    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        CheckBox chk = (CheckBox)e.Row.FindControl("checkbox1");
        TextBox txt = (TextBox)e.Row.FindControl("quantity");
    
        chk.Attributes["onclick"] = string.Format("ChangeQuantityEnable('{0}', this.checked);", txt.ClientID);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a traditional ASP.NET GridView. Inside of it I have a Template Field
I've got an asp.net gridview inside an updatepanel. One of the fields I have
I have a GridView with a row number (Container.DataItemIndex) column in ASP.NET (1,2,3,4, ...)
I have a GridView in ASP.net where I have a CheckBox column. The user
I have a question for you regarding ASP.NET's GridView and performing an If Statement
i'm using ASP.NET ,i have a gridview with a checkbox element , i want
I have an ASP.NET GridView with paging enabled. The list of page indexes are
I am new ASP.NET and I have never used a GridView or DataGrid, but
I have a Jquery Accordion and I have a asp.net GridView below that. When
I have problems binding both a telerik RadGrid and a plain vanilla ASP.NET GridView

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.