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

Unable to select entire row when checked the checkbox of that row

1 Answer 160 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Ravi Prakash
Top achievements
Rank 1
Ravi Prakash asked on 04 Feb 2010, 06:38 AM
Hi All,
          I have check boxes in the gridview for each row. When i checked a particular row's checkbox the enrire row should be selected. It is working but when i checked another checkbox, the previous checked row is not selecting. Only current row is selected. I need to select all the rows which i have checked.

I tried in this way,

            

 

private void GridView_MouseUp(object sender, MouseEventArgs e)

 

{

    for

(int i = 0; i < GridView.Rows.Count; i++)

 

    {
        if (GridView.Rows[i].Cells["chk"].Selected == true) //CellElement.RowInfo.IsSelected)

 

    {

 

        //GridView.Rows[i].Cells["chk"].RowInfo.IsSelected = true; 
        GridView.Rows[i].Cells["chk"].CellElement.RowElement.IsSelected = true;

 

    }

 

    else //if (Convert.ToBoolean(GridView.Rows[i].Cells["chk"].RowInfo.IsSelected))

 

    {

 

 

        //GridView.Rows[i].Cells["chk"].RowInfo.IsSelected = false;

 

        GridView.Rows[i].Cells[

"chk"].CellElement.RowElement.IsSelected = false;

 

    }

}                   

i tried with mousedown and mouse click also. It is not working.
note: The checkbox column is added to grid programatically.



       

1 Answer, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 04 Feb 2010, 09:18 AM
Hi Ravi Prakash,

RadGridView manages row selection internally. By default multi row select mode is disabled and you can select only one row. You have to set the MultiSelect property to true to enable multiple row selection. However, if you don't like the default selection behavior and if you want to replace it with a checkbox click, the best way to achieve this is not to use row selection, but to customize the row appearance. The following KB article demonstrates this. Should you have any further questions, don't hesitate to contact us.

Kind regards,
Jack
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
Tags
GridView
Asked by
Ravi Prakash
Top achievements
Rank 1
Answers by
Jack
Telerik team
Share this question
or