Can't get radio buttons to work in side of a nested repeater
-
Hi, I'm using some nestedrepeaters to display some data from a database. Inside of the second repeater I would like to use radio buttons to select data with. The only problem is that I can't get the button groups set correctly. Here is the aspx file: < %@ Page language="c#" Codebehind="NestedRepeater.aspx.cs" Inherits="NestedRepeater.NestedRepeater" % > < %@ Import Namespace="System.Data" % > < html > < body > < form runat=server > < !-- start parent repeater -- > < asp:repeater id="parentRepeater" runat="server" > < itemtemplate > < b > < %# DataBinder.Eval(Container.DataItem,"question") % > < /b > < br > < !-- start child repeater -- > < asp:Repeater id="childRepeater" datasource=' < %# ((DataRowView)Container.DataItem) .Row.GetChildRows("myrelation") % > ' runat="server" onitemdatabound="questions_ItemDataBound" > < itemtemplate > < asp:radioButton id="button" runat="server" > < /asp:radioButton > < %# DataBinder.Eval(Container.DataItem, "[\"opt\"]")% > < br / > < /itemtemplate > < /asp:Repeater > < !-- end child repeater -- > < /itemtemplate > < /asp:repeater > < !-- end parent repeater -- > < /form > < /body > < /html > and here is the c# file: using System; using System.Data; using System.Data.Odbc; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; namespace NestedRepeater { public class NestedRepeater : System.Web.UI.Page { protected System.Web.UI.WebControls.Repeater parentRepeater; protected System.Web.UI.WebControls.RadioButton button; public void Page_Load(object sender, EventArgs e) { //Create the connection and DataAdapter for the Authors table. OdbcConnection cnn = new OdbcConnection("Dsn=mysqldb;Uid=bigtone78; Pwd="); OdbcDataAdapter cmd1 = new OdbcDataAdapter("select * from questions",cnn); //Create and fill the DataSet. DataSet ds = new DataSet(); cmd1.Fill(ds,"questions"); //Create a second DataAdapter for the Titles table. OdbcDataAdapter cmd2 = new OdbcDataAdapter("select * from options",cnn); cmd2.Fill(ds,"options"); //Create the relation bewtween
-
Hi, I'm using some nestedrepeaters to display some data from a database. Inside of the second repeater I would like to use radio buttons to select data with. The only problem is that I can't get the button groups set correctly. Here is the aspx file: < %@ Page language="c#" Codebehind="NestedRepeater.aspx.cs" Inherits="NestedRepeater.NestedRepeater" % > < %@ Import Namespace="System.Data" % > < html > < body > < form runat=server > < !-- start parent repeater -- > < asp:repeater id="parentRepeater" runat="server" > < itemtemplate > < b > < %# DataBinder.Eval(Container.DataItem,"question") % > < /b > < br > < !-- start child repeater -- > < asp:Repeater id="childRepeater" datasource=' < %# ((DataRowView)Container.DataItem) .Row.GetChildRows("myrelation") % > ' runat="server" onitemdatabound="questions_ItemDataBound" > < itemtemplate > < asp:radioButton id="button" runat="server" > < /asp:radioButton > < %# DataBinder.Eval(Container.DataItem, "[\"opt\"]")% > < br / > < /itemtemplate > < /asp:Repeater > < !-- end child repeater -- > < /itemtemplate > < /asp:repeater > < !-- end parent repeater -- > < /form > < /body > < /html > and here is the c# file: using System; using System.Data; using System.Data.Odbc; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; namespace NestedRepeater { public class NestedRepeater : System.Web.UI.Page { protected System.Web.UI.WebControls.Repeater parentRepeater; protected System.Web.UI.WebControls.RadioButton button; public void Page_Load(object sender, EventArgs e) { //Create the connection and DataAdapter for the Authors table. OdbcConnection cnn = new OdbcConnection("Dsn=mysqldb;Uid=bigtone78; Pwd="); OdbcDataAdapter cmd1 = new OdbcDataAdapter("select * from questions",cnn); //Create and fill the DataSet. DataSet ds = new DataSet(); cmd1.Fill(ds,"questions"); //Create a second DataAdapter for the Titles table. OdbcDataAdapter cmd2 = new OdbcDataAdapter("select * from options",cnn); cmd2.Fill(ds,"options"); //Create the relation bewtween
Hi there, You can try to move the questions_ItemDataBound handler to the parent repeater, and you also need to change your code a bit the handler to get the radio button. There are a couple of examples that have been done for you: http://support.microsoft.com/default.aspx?scid=kb;EN-US;306154[^] http://www.c-sharpcorner.com/Code/2002/Aug/MasterDetailedDisplay.asp[^]