This is a migrated thread and some comments may be shown as answers.

Toggle Individual Row with check box

2 Answers 59 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jack Voss
Top achievements
Rank 1
Jack Voss asked on 04 Apr 2012, 03:29 PM
I looked at the grid demo here

http://demos.telerik.com/aspnet-ajax/grid/examples/programming/selectrowwithcheckbox/defaultcs.aspx

Unfortunately it references "ToggleRowSelection" in the ASP page for the row on CheckedChange.
When you look at the code demo, ToggleRowSelection does not exist. 

The code for when you select the header does indeed exist.

protected void ToggleSelectedState(object sender, EventArgs e)
        {
            CheckBox headerCheckBox = (sender as CheckBox);
            foreach (GridDataItem dataItem in RadGrid1.MasterTableView.Items)
            {
                (dataItem.FindControl("CheckBox1") as CheckBox).Checked = headerCheckBox.Checked;
                dataItem.Selected = headerCheckBox.Checked;
            }
        }


So what I am trying to find out,  what is the code for checking that individual row?

What should be in ToggleRowSelection

2 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 04 Apr 2012, 04:15 PM
Hi,

I have tried the same code as in the demo and is working fine at my end. Please take a look into the following code.

C#:
protected void ToggleRowSelection(object sender, EventArgs e)
{
    ((sender as CheckBox).NamingContainer as GridItem).Selected = (sender as CheckBox).Checked;
}

Thanks,
Shinu.
0
Jack Voss
Top achievements
Rank 1
answered on 04 Apr 2012, 04:44 PM
Apparantly I am just blind.

Thank you.
Tags
Grid
Asked by
Jack Voss
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Jack Voss
Top achievements
Rank 1
Share this question
or