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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:00:06+00:00 2026-05-16T16:00:06+00:00

I have a gridview with a cheackbox and a dropdown. The checkbox, by default,

  • 0

I have a gridview with a cheackbox and a dropdown.

The checkbox, by default, is not checked.
The dropdownlist, by default, is disabled.

In the edit mode of the gridview, when the user clicks the checkbox I want the dropdown to become enabled. If I could do this client side that would be awesome, if not I want to do it server side WITHOUT having to click update and then edit again.

This is in C#

Thanks!

What I tried:

The grdiview is based off of a data source, so originally I tried basing the enabled value of the dropdown list off of the data Eval of the checkbox datavalue. However this required checking the box, clicking update and then edit for the ddl to be enabled. Then I thought maybe autopostback would all the user not to have to click update and then edit again. This did not work. However what I really want it a client side solution. I think the way it would have to work is and event on the checkbox would have to actually enable the dropdown list, I don’t think the dropdown list can listen for the checkbox to be checked. However I don’t know how to reference a control from another control in asp code. So maybe I would say something like OnCheckChanged = if Checked then ddl.enabled = true? But i’m not sure how to write that, and I don’t know that I can force that event of the checkbox to be evaluated client side.

@Tim – I tried this:

in the rowdatabound event:

CheckBox chk = e.Row.FindControl("checkbox1") as CheckBox;
                DropDownList ddl = e.Row.FindControl("dropdownlist1") as DropDownList;
                chk.Attributes.Add("onclick", "document.getElementById('" + ddl.ClientID + "').enabled = this.checked;");

When I click edit this code DOES get hit so the onclick event IS getting added tot he checkbox. But when I click the checkbox the dropdown list does not become enabled.

Thanks Tim! This is the working solution.

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)\
{
if ((row.RowType == DataControlRowType.DataRow) && ((row.RowState & DataControlRowState.Edit) > 0))
CheckBox chk = e.Row.FindControl("checkbox1") as CheckBox;
            DropDownList ddl = e.Row.FindControl("dropdownlist1") as DropDownList;
            chk.Attributes.Add("onclick", "document.getElementById('" + ddl.ClientID + "').disabled = !this.checked;");
}
  • 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-16T16:00:07+00:00Added an answer on May 16, 2026 at 4:00 pm

    Use RowDataBound to add the client-side event to your checkbox:

       GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
            Select Case e.Row.RowState
                Case DataControlRowState.Edit
                    Dim chk As CheckBox = DirectCast(e.Row.FindControl("MyCheckboxID"), CheckBox)
                    Dim ddl As DropDownList = DirectCast(e.Row.FindControl("MyDropdownlistID"), DropDownList)
                    chk.Attributes.Add("onclick", "document.getElementById('" & ddl.ClientID & "').disabled = ! this.checked;")
            End Select
        End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Checkbox template column in a ASP.NET 3.5 GridView. Now the user
I have a GridView in which I want to embed a checkbox into the
I have used checkbox column in gridview. I want to check status of that
I have a GridView in ASP.net where I have a CheckBox column. The user
I have a gridview which contains controls like checkbox dropdownlist textbox etc.. These controls
I have a gridview that contains data. I want the user to be able
i'm using ASP.NET ,i have a gridview with a checkbox element , i want
I have a gridview with a checkbox in it and I'm trying to do
I have a gridview with Template field. I add a checkbox in templatefield .
I have GridView on my page: <%@ Page Language=C# AutoEventWireup=true CodeFile=Default.aspx.cs Inherits=_Default %> <!DOCTYPE

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.