troubleshooting Question

how to reference the id of my checkbox in a dynamic GridView control

Avatar of brgdotnet
brgdotnetFlag for United States of America asked on
2 Comments2 Solutions163 ViewsLast Modified:
In my C# code I am creating a dynamic GridView control and one of the columns is a check box. In my C# code I am also assigning an ID to my
check box control in my RowDataBound event.  ===>   chkBox.ID = "CheckBox" + e.Row.RowIndex

However when my page is rendered, the id of the checkbox is prepended with the text "MainContent_myGrid_"  and appended by and underscore and then the number.

<input id = "MainContent_myGrid_CheckBox3_3" type="checkBox" name="ctl00$MainContent$myGrid$ct103>

I want to be able to disable the checkbox using Java script.How can I reference the check box control by the ID I assigned to it in the GridView control?
Is there a way to do it, without having to reference the prepended "MainContent_myGrid_" text and the appended text of underscore followed by the number
of the check box?
Nitin Sontakke

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 2 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 2 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros