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 4108640
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T21:41:12+00:00 2026-05-20T21:41:12+00:00

I have a dynamic (allows addition of rows on the fly) an ASP gridview

  • 0

I have a dynamic (allows addition of rows on the fly) an ASP gridview that has a dropdownlist in one of its columns. I would like to take an action enable/disable the textbox in the column after depending on the selection in the dropdownlist during data entry.

Any help will be highly appreciated.

  • 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-20T21:41:13+00:00Added an answer on May 20, 2026 at 9:41 pm

    You can do this easily with jQuery. With a bit of modification, you can get it working exactly as you want it to.

    First, add the following to your <head> tag:

    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
    <script type="text/javascript">
    $(document).ready(function () {
       $(".ddlClass").change(function () {
          var txt = $(this).closest("tr").find(".txtClass");
          if ($(this).val() == 0) {
             txt.css("background", "#cccccc");
             txt.attr("disabled", "disabled");
          }
          else {
             txt.css("background", "#ffffff");
             txt.attr("disabled","");
          }
        });
    });
    

    Next, create your gridview and add template columns for your textbox and dropdown list. In the code below, notice that the dropdown list has been given a class “ddlClass” and the textbox has been given a class “txtClass”. You can change these as you see fit.

    <asp:gridview runat="server" ID="gvw" AutoGenerateColumns="false">
                <Columns>
                    <asp:BoundField DataField="field1" />
                    <asp:BoundField DataField="field2" />
                    <asp:TemplateField HeaderText="Name">
                        <ItemTemplate>
                            <asp:TextBox runat="server" ID="txtName" CssClass="txtClass"></asp:TextBox>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <select class="ddlClass">
                                <option value="1">Enabled</option>
                                <option value="0">Disabled</option>
                            </select>
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:gridview>
    

    The .ready function attaches a click event to each dropdownlist with the class “ddlClass”. When changed, the code will find the textbox with the class “txtClass” in the same row as the dropdownlist and then enable/disable accordingly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that has a dynamic javascript calendar, which allows users
I have a fairly simple MVC view that allows for dynamic text input that
I have a CMS app that allows custom fields to be added. One type
I have this function in my custom dynamic array class that allows the user
I have a web application that builds a dynamic PDF with FPDF and allows
We have an IDE for machine automation that allows its users to develop solutions
I have a dynamic form that allow to add many fields dynamically, I Know
I have some divs that have dynamic heights controlled by a 'click' function as
I have some divs that have dynamic heights controlled by a 'click' function as
I have a dynamic value that is being stored in a PHP variable. The

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.