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:RadGridrunat="server"ID="grd1"OnNeedDataSource="grd1_NeedDataSource"> <MasterTableViewAutoGenerateColumns="False"><Columns><telerik:GridTemplateColumnHeaderText="Radiobutton header"UniqueName="col1"><ItemTemplate><asp:RadioButtonID="rbType"runat="server"Text='<%# DataBinder.Eval(Container.DataItem, "rbEnableorDisable")%>' /></ItemTemplate></telerik:GridTemplateColumn><telerik:GridTemplateColumnHeaderText="FirstName header"UniqueName="col2"><ItemTemplate><asp:LabelText='<%# DataBinder.Eval(Container.DataItem, "Name")%>' runat="server" /></ItemTemplate></telerik:GridTemplateColumn></Columns></MasterTableView></telerik:RadGrid>Codebehind
dt= NewDataTabledt.Columns.Add("rbEnableorDisable")dt.Columns.Add("FirstName")Dimrb AsRadioButtonrb = NewRadioButtonForeach 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 = TrueEndifdr.Item("FirstName") = item.FirstNamedr.Item("rbEnableOrDisable") = rb//?Code for inserting a radio button objectdt.Rows.Add(dr)NextWithgrd1.DataSource = dt.DataBind()EndWithSo 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)