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

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?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nitin SontakkeDeveloperCommented:
Please refer to this for the detailed discussion on the subject. I think what you need is ClientId property.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Prakash SamariyaIT ProfessionalCommented:
In your RowDataBound event, add css class to checkbox like below
chkBox.CssClass= "CheckBox" + e.Row.RowIndex 

Open in new window

So when it will render HTML, it will have attribute class with your given pattern like below
<input id = "MainContent_myGrid_CheckBox3_3" type="checkBox" name="ctl00$MainContent$myGrid$ct103 class="CheckBox3">

Open in new window

Now, you have to get checkbox using that class
var x = document.getElementsByClassName("CheckBox3");

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.