Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Can't get radio buttons to work in side of a nested repeater

Can't get radio buttons to work in side of a nested repeater

Scheduled Pinned Locked Moved ASP.NET
csharphtmldatabasedesignsysadmin
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bigtone78
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • B bigtone78

      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

      M Offline
      M Offline
      minhpc_bk
      wrote on last edited by
      #2

      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[^]

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups