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 DataTabledt.Columns.Add("rbEnableorDisable")dt.Columns.Add("FirstName")Dim rb As RadioButtonrb = New RadioButtonFor each item in itemlist //some data iteration declared elsewheredr = dt.NewRow()If (Condition)rb.Text = "Should be Disabled"rb.Enabled = FalseElserb.Text = "Should be Enabled"rb.Enabled = TrueEnd ifdr.Item("FirstName") = item.FirstNamedr.Item("rbEnableOrDisable") = rb//?Code for inserting a radio button objectdt.Rows.Add(dr)NextWith grd1.DataSource = dt.DataBind()End WithSo 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)
