We help IT Professionals succeed at work.

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

brgdotnet
brgdotnet asked
on
157 Views
Last Modified: 2017-03-29
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.
Example

<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?
Comment
Watch Question

Developer
CERTIFIED EXPERT
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION
Prakash SamariyaIT Professional
CERTIFIED EXPERT
Top Expert 2015
Commented:
This problem has been solved!
(Unlock this solution with a 7-day Free Trial)
UNLOCK SOLUTION

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions