enable disable checkboxes in datagrid

I have a datagrid that has checkbox and dropdown templates, I want to have a javascript function would grab a checkbox id  whichever checkbox in datagrid gets checked. So, function will loop thru datagrid rows and find the checked ones. How can I do that? Once it find that I want to be able to disable some of the rows checkboxes. That gets me confused how to do that?
Who is Participating?
You can handle the OnCheckedChanged event of the checkbox and disable the textbox in the event handler. Here are the steps in detail:

1. In the .aspx file, add an OnCheckChanged attribute and bind it to the method you want to call. The template may look like this:

       <asp:CheckBox id="CheckBox1" OnCheckedChanged="Check_Clicked" runat="server" AutoPostBack="True">

2. Create the "Check_Click" method in the code-behide file:

    public void Check_Clicked(object sender, System.EventArgs e)

3. Most likely, you may need to retrieve the values in the row where the selected checkbox is located. However, the System.EventArgs does not contain any
information about the current row, so we need to use the following method to achieve this (the following code is in the Check_Clicked method):

               CheckBox cb=(CheckBox)sender;
        DataGridItem dgi=(DataGridItem)cb.NamingContainer;
        HyperLink hl=(HyperLink)dgi.Cells[0].Controls[1];     //revise the code to retrieve the control you want
                 ...  //Do other tasks you want, such as disabling a given textbox

An article that can help you on your way:
Using CheckBoxes within the DataGrid control to select records
jaws1021Author Commented:
I am sorry I should have written I need this on client side, so without using ajax I don't want to my page to refresh. I actually did whole project at the server side and on checkchanged event everything was working perfect except page refresh then I tried to put ajax, ajax stopped refreshing whole page but didn't stop flickering dropdown , which I found out later that was bug for IE browser 6, which is okay for the other ones such as firefox or even maybe for IE7, so now I am tried of wasting my time and I wan to to do old fashion javascript so it will be no refreshing ... I need this above code to be doing same thing on javascript, I am not that good at javascript  but I will manage. Thanks.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.