Hi Rob,
A RadCheckBox is bound in the same way as an <asp:CheckBox>. I created an example for you that also shows how you can use its server CheckedChanged event:
protected
void
cb1_CheckedChanged(
object
sender, EventArgs e)
{
GridDataItem itm = ((sender
as
Control).NamingContainer
as
GridDataItem);
//in my example all templates are the same to make it shorter, in a real case they may differ
RadLabel lbl = itm.FindControl(
"lbl1"
)
as
RadLabel;
if
(!((itm
is
GridDataInsertItem) && itm.IsInEditMode))
{
//the way to tell one mode from the other is here:
//an Insert item will not have data associated with it already, that's why the object can be null
lbl.Text = itm.GetDataKeyValue(
"textField"
).ToString();
}
else
{
lbl.Text = DateTime.Now.ToString();
}
}
protected
void
rg1_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
(sender
as
RadGrid).DataSource = GetDummyData();
}
protected
DataTable GetDummyData()
{
DataTable tbl =
new
DataTable();
tbl.Columns.Add(
new
DataColumn(
"theBoolField"
,
typeof
(
bool
)));
tbl.Columns.Add(
new
DataColumn(
"textField"
,
typeof
(
string
)));
tbl.Columns.Add(
new
DataColumn(
"numField"
,
typeof
(
int
)));
tbl.Columns.Add(
new
DataColumn(
"secondTextField"
,
typeof
(
string
)));
tbl.Rows.Add(
new
object
[] {
true
,
"one"
, 1,
"red"
});
tbl.Rows.Add(
new
object
[] {
false
,
"two"
, 2,
"green"
});
tbl.Rows.Add(
new
object
[] {
true
,
"three"
, 3,
"blue"
});
tbl.Rows.Add(
new
object
[] {
true
,
"four"
, 4,
"pink"
});
return
tbl;
}
Regards,
Marin Bratanov
Progress Telerik
Get
quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers.
Learn More.