I am trying to create a RowSelection Checkbox Column on my grid programatically, no Templates on the ASCX file. Reason for programatically creating it is because I am trying to create a "Wrapper" class using the RADGrid, so I can easily use it all over my application directly in my code.
I first tried using Telerik.Web.UI.GridClientSelectColumn. Problem is that because it's a "ClientSide" selection, it kept losing the SelectedRow values on PageChange. I looking into retaining the SelectedRows using JavaScript, but from what I can tell, it wouldn't be feasible for my particular situation (Passing the selected rows back and forth between client/server seemed way to complicated and possible unworkable for my situation). So I decided to switch to Server-Side code. From what I gathered, in order to do that I had to use a different ColumnType, so I found Telerik.Web.UI.GridCheckBoxColumn. I have a few problems that I cant seem to figure out for the life of me...
1) The column when rendered, is disabled..have no clue how to enable it
2) The column is missing the checkbox in the header as a "Select All" feature
3) After creating the column, in the related event methods, I can't seem to obtain a reference to said column.
- ie: In the ItemCreated() event, e.Item.FindControl("chkSelect") returns Nothing
Below are snippets of my code...
Column Creation Code:
Grid's ItemCreated() event:
The above code doesn't work, crashing on the FindControl() method because it doesn't find the control "chkSelect".
Any help would be greatly appreciated!
I first tried using Telerik.Web.UI.GridClientSelectColumn. Problem is that because it's a "ClientSide" selection, it kept losing the SelectedRow values on PageChange. I looking into retaining the SelectedRows using JavaScript, but from what I can tell, it wouldn't be feasible for my particular situation (Passing the selected rows back and forth between client/server seemed way to complicated and possible unworkable for my situation). So I decided to switch to Server-Side code. From what I gathered, in order to do that I had to use a different ColumnType, so I found Telerik.Web.UI.GridCheckBoxColumn. I have a few problems that I cant seem to figure out for the life of me...
1) The column when rendered, is disabled..have no clue how to enable it
2) The column is missing the checkbox in the header as a "Select All" feature
3) After creating the column, in the related event methods, I can't seem to obtain a reference to said column.
- ie: In the ItemCreated() event, e.Item.FindControl("chkSelect") returns Nothing
Below are snippets of my code...
Column Creation Code:
'***************************************
' Initialize Variables
'***************************************
Dim objColumn_Select As New Telerik.Web.UI.GridCheckBoxColumn
'***************************************
' Add Button Column To Grid
'***************************************
Me.gridMain.Columns.Add(objColumn_Select)
'***************************************
' Define Column Properties
'***************************************
With objColumn_Select
.ItemStyle.HorizontalAlign = HorizontalAlign.Center
.HeaderText = ""
.UniqueName = "chkSelect"
End With
Grid's ItemCreated() event:
'***************************************
' Add Handler To Custom ItemPreRender Event
'***************************************
AddHandler e.Item.PreRender, AddressOf Me.gridMain_ItemPreRender
'***************************************
' Add "OnCheckedChanged" Event
'***************************************
CType(e.Item.FindControl("chkSelect"), CheckBox).Attributes("onCheckedChanged") = "gridMain_ToggleRowSelection"
The above code doesn't work, crashing on the FindControl() method because it doesn't find the control "chkSelect".
Any help would be greatly appreciated!