I need to add a custom radio button control that I created based on an if condition to my GridView. My radiobutton will be enabled or disabled based on this condition and will have the text changed as well.I'm trying to figure out how to add a radiobutton object into my data row instead of a stringdt.Columns.Add("FirstName").
<
telerik:RadGrid
runat
=
"server"
ID
=
"grd1"
OnNeedDataSource
=
"grd1_NeedDataSource"
>
<
MasterTableView
AutoGenerateColumns
=
"False"
>
<
Columns
>
<
telerik:GridTemplateColumn
HeaderText
=
"Radiobutton header"
UniqueName
=
"col1"
>
<
ItemTemplate
>
<
asp:RadioButton
ID
=
"rbType"
runat
=
"server"
Text='<%# DataBinder.Eval(Container.DataItem, "rbEnableorDisable")%>' />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
HeaderText
=
"FirstName header"
UniqueName
=
"col2"
>
<
ItemTemplate
>
<
asp:Label
Text='<%# DataBinder.Eval(Container.DataItem, "Name")%>' runat="server" />
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
Codebehind
dt=
New
DataTable
dt.Columns.Add(
"rbEnableorDisable"
)
dt.Columns.Add(
"FirstName"
)
Dim
rb
As
RadioButton
rb =
New
RadioButton
For
each item in itemlist //some data iteration declared elsewhere
dr = dt.NewRow()
If
(Condition)
rb.Text =
"Should be Disabled"
rb.Enabled =
False
Else
rb.Text =
"Should be Enabled"
rb.Enabled =
True
End
if
dr.Item(
"FirstName"
) = item.FirstName
dr.Item(
"rbEnableOrDisable"
) = rb//?Code for inserting a radio button object
dt.Rows.Add(dr)
Next
With
grd1
.DataSource = dt
.DataBind()
End
With
So far with this code I am only able to display the radiobutton text if i havedr.Item("rbEnableOrDisable") = rb.Text.I need to display the whole radiobutton object(show the text and if it's enabled or disabled among others)I triedLocationData.Columns.Add(New DataColumn("rbType", GetType(RadioButton)))but it seems I need to append to the ItemTemplateAlso tried adding the whole column dynamic with:grd1.Controls.Add(rb)