Checkbox in GridView

Hi all, hope in your help.

If select in GV a check box from 1 row then you want all other rows in the GridView to be disabled leaving the current row enabled…
I tried this code but not working … can you help me?

    protected void CheckBox1_CheckedChanged(object sender, EventArgs e)
    {
        CheckBox chkTest = (CheckBox)sender;
        GridViewRow GridView1 = (GridViewRow)chkTest.NamingContainer;

        if (chkTest.Checked)
        {
           GridView1.BackColor = System.Drawing.Color.Yellow;
        }
    }


    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            DropDownList DDL = (DropDownList)e.Row.FindControl("DDL");

            foreach (GridViewRow gvr in GridView1.Rows)
            {
                if (((CheckBox)gvr.FindControl("chkSelect")).Checked)
                {
                    DDL.Enabled = false;
                }
                else
                {
                    DDL.Enabled = true;
                }
            }
        }
    }

Hi

You would probably want to do something like this with javascript and not server-side code. Your code above only checks on page load if it is checked or not to disable all others. So if nothing is checked by default, that would not work.