I am creating my RadGrid programmatically in the Page_Init. During the process I am creating a GridTemplateColumn that will be used as a CheckBox. I am doing this to convert my database value to a boolean. I have also added an attribute to the checkbox so that when they click the checkbox I want to run some javascript. In that javascript I would like to gather some of the values in the other cells on the row of the checkbox I just clicked in. So say I have 5 columns in my grid, the third column has checkboxes and there are a total of 100 rows. When I click the checkbox of the the third row, I want to gather the values of all 5 columns for the row of the checkbox I clicked. I see a lot of Client-side scripting methods but unfortunately am new to the RadGrid. I did set the OnGridSelected to a javascript function to get the RadGrid object but that is as far as I know how to go. Please let me know.
RadGrid1.ClientSettings.ClientEvents.OnGridCreated =
"GetGridObject"
var RadGrid1;
function GetGridObject(sender, eventArgs)
{
RadGrid1 = sender;
}
Public
Class
MyTemplate
Implements
ITemplate
Protected
textBox
As
TextBox
Protected
boolValue
As
CheckBox
Private
colname
As
String
Public
Sub
New
(
ByVal
cName
As
String
)
colname = cName
End
Sub
Public
Sub
InstantiateIn(
ByVal
container
As
System.Web.UI.Control)
Implements
ITemplate.InstantiateIn
boolValue =
New
CheckBox()
boolValue.ID = colname
AddHandler
boolValue.DataBinding, _
AddressOf
boolValue_DataBinding
boolValue.Enabled =
True
container.Controls.Add(boolValue)
End
Sub
Sub
boolValue_DataBinding(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Dim
cBox
As
CheckBox =
DirectCast
(sender, CheckBox)
Dim
container
As
GridDataItem =
DirectCast
(cBox.NamingContainer, GridDataItem)
If
((
DirectCast
(container.DataItem, DataRowView))(colname)) = 1
Or
((
DirectCast
(container.DataItem, DataRowView))(colname)) =
True
Then
cBox.Checked =
True
Else
cBox.Checked =
False
End
If
cBox.Attributes.Add(
"onClick"
,
"Javascript:fnOpenGeoInfoView(''
)"
)
End
Sub
Sub
textBox_DataBinding(
ByVal
sender
As
Object
,
ByVal
e
As
EventArgs)
Dim
cTextBox
As
TextBox =
DirectCast
(sender, TextBox)
Dim
container
As
GridDataItem =
DirectCast
(cTextBox.NamingContainer, GridDataItem)
cTextBox.Text = (
DirectCast
(container.DataItem, DataRowView))(colname).ToString()
End
Sub
End
Class