Manikandan
Top achievements
Rank 1
Manikandan
asked on 26 Jun 2009, 06:18 AM
How to selece checkbox in the current row on cell click?
5 Answers, 1 is accepted
0
gerbrand
Top achievements
Rank 2
answered on 26 Jun 2009, 12:53 PM
Hello,
Try the following:
In the cellclick event of the radgrid add this line of code.
where in "Cells" the column index number is of your checkbox
Try the following:
In the cellclick event of the radgrid add this line of code.
where in "Cells" the column index number is of your checkbox
private void radgrid_CellClick(object sender, GridViewCellEventArgs e) |
{ |
radgrid.MasterGridViewTemplate.Rows[e.RowIndex].Cells[0].Value = true; |
} |
0
gerbrand
Top achievements
Rank 2
answered on 26 Jun 2009, 01:03 PM
An update:
If you want that when a second time the cell is clicked it unselects it add this:
If you want that when a second time the cell is clicked it unselects it add this:
private void radgrid_CellClick(object sender, GridViewCellEventArgs e) |
{ |
if (!(bool)radgrid.MasterGridViewTemplate.Rows[e.RowIndex].Cells[0].Value) |
{ |
radgrid.MasterGridViewTemplate.Rows[e.RowIndex].Cells[0].Value = true; |
}else |
{ |
radgrid.MasterGridViewTemplate.Rows[e.RowIndex].Cells[0].Value = false; |
} |
} |
0
Manikandan
Top achievements
Rank 1
answered on 27 Jun 2009, 05:23 AM
I had made my checkbox column alone radgrid.readonly=False and for all other columns radgrid.readonly=true. After doing this the cell click event doesn't fire when i click on the other columns. I doesnt want the user to edit the data.So i had made my radgrid.readonly=true. So that i cant do that in the cell click event .
0
gerbrand
Top achievements
Rank 2
answered on 29 Jun 2009, 12:02 PM
Hi,
I looked at my code and I have the same situation as you.
My grid has the property AllowEditRow = false under MasterGridViewTemplate.
In my code for adding the columns I have the checkbox row property ReadOnly = false. But my other column don't have the property ReadOnly = true.
Even so it isn't possible to edit the rows. even with the keystroke F2.
If this doesn't do the trick post some sample code of you project.
I looked at my code and I have the same situation as you.
My grid has the property AllowEditRow = false under MasterGridViewTemplate.
In my code for adding the columns I have the checkbox row property ReadOnly = false. But my other column don't have the property ReadOnly = true.
Even so it isn't possible to edit the rows. even with the keystroke F2.
If this doesn't do the trick post some sample code of you project.
0
Developer
Top achievements
Rank 1
answered on 23 Apr 2010, 10:50 AM
Ok this is a very old thread, but an even smaller approach would be:
Private Sub GridView1_CellClick(ByVal sender As Object, ByVal e As Telerik.WinControls.UI.GridViewCellEventArgs) Handles GridView1.CellClick |
ToggleRowSelect(sender, e) |
Try |
' Assuming first cell is of CheckBoxColumn |
Dim flag As Boolean = DirectCast(GridView1.MasterGridViewTemplate.Rows(e.RowIndex).Cells(0).Value, Boolean) |
GridView1.MasterGridViewTemplate.Rows(e.RowIndex).Cells(0).Value = Not flag |
Catch ex As Exception |
MessageBox.Show(ex.Message) |
End Try |
End Sub |