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
bigtone78
Posts
-
Can't get radio buttons to work in side of a nested repeater -
Restore a databaseI've tried that but I get some big long error about my data and log files not being found.
-
Restore a databaseDoes anyone know how to restore a .bak file to a MS SQL Sever. I think the .bak file is a backup of a .mdf file but I don't have the logs or any of the associated files.
-
I can't get my codebehind to workI can't get my codebehind to work. Here is the code behind code: namespace nestedRepeaters { using System.Data; using System.Data.Odbc; public class nestedRepeater : System.Web.UI.Page { public System.Web.UI.WebControls.Repeater parentRepeater; static void Main() { } public void Page_Load(object sender, System.EventArgs e) { //Create the connection and DataAdapter for the Authors table. string sConnString = "Dsn=mysqldb;Uid=bigtone78 ; Pwd="; OdbcConnection cnn = new OdbcConnection(sConnString); OdbcDataAdapter cmd1 = new OdbcDataAdapter("select * from questions",cnn); //Create and fill the DataSet. DataSet ds = new DataSet(); cmd1.Fill(ds,"questions"); //Insert code in step 4 of the next section here. //Bind the Authors table to the parent Repeater control, and call DataBind. parentRepeater.DataSource = ds.Tables["questions"]; Page.DataBind(); //Close the connection. cnn.Close(); } } } and here is where I call it in the aspx file: <%@ Page language="c#" Codebehind="test1.aspx.cs" Debug="true" AutoEventWireup="false" Inherits="nestedRepeaters.nestedRepeater" %> nothing shows up all I get is a blank screen. I think it has something to do with my main method. I don't think i should have one but the code doesnt compile if if dont use one.
-
I can't get my codebehind to workNothing works I get a blank screen...... I think maybe its the main function. I dont think i need one but if i dont use one the code doesnt compile
-
I can't get my codebehind to workI can't get my codebehind to work. Here is the code behind code: namespace nestedRepeaters { using System.Data; using System.Data.Odbc; public class nestedRepeater : System.Web.UI.Page { public System.Web.UI.WebControls.Repeater parentRepeater; static void Main() { } public void Page_Load(object sender, System.EventArgs e) { //Create the connection and DataAdapter for the Authors table. string sConnString = "Dsn=mysqldb;Uid=bigtone78 ; Pwd="; OdbcConnection cnn = new OdbcConnection(sConnString); OdbcDataAdapter cmd1 = new OdbcDataAdapter("select * from questions",cnn); //Create and fill the DataSet. DataSet ds = new DataSet(); cmd1.Fill(ds,"questions"); //Insert code in step 4 of the next section here. //Bind the Authors table to the parent Repeater control, and call DataBind. parentRepeater.DataSource = ds.Tables["questions"]; Page.DataBind(); //Close the connection. cnn.Close(); } } } and here is where I call it in the aspx file: <%@ Page language="c#" Codebehind="test1.aspx.cs" Debug="true" AutoEventWireup="false" Inherits="nestedRepeaters.nestedRepeater" %>
-
dataviewNevermind I figured out this problem but it still doesnt work. The data still doesnt appear in the nested repeater.
-
dataviewI am trying to set a data relation and I keep getting an error saying: The relation is not parented to the table to which this DataView points. What does this mean. Here is the vb.net code that im using: <%@ Import Namespace="System.Data.Odbc" %> <%@ Import Namespace="System.Data" %> sub Page_Load Dim sConnString As String = "Dsn=mysqldb;" & _ "Uid=bigtone78;" & _ "Pwd=" Dim oODBCConnection As New OdbcConnection(sConnString) Dim myInsertQuery As String = "SELECT * FROM questions" Dim cmd1 As odbcdataAdapter = New odbcdataAdapter(myInsertQuery, oODBCConnection) Dim ds As DataSet = New DataSet() cmd1.Fill(ds, "questions") Dim sqlQuery as String = "select * from options" Dim cmd2 As odbcdataAdapter = New odbcdataAdapter(sqlQuery, oODBCConnection) cmd2.Fill(ds, "options") ds.Relations.Add(new DataRelation("myrelation", ds.Tables("questions").Columns("id"), ds.Tables("options").Columns("qID"))) questions.DataSource= ds.Tables("questions") questions.DataBind() oODBCConnection.close() end sub sub questions_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) if e.item.itemtype = ListItemType.Item or e.item.ItemType = ListItemType.AlternatingItem then Dim dv as DataRowView = e.Item.DataItem if not dv is nothing then Dim nestedRepeater as Repeater = e.item.FindControl("opts") if Not nestedrepeater Is Nothing then nestedRepeater.DataSource = dv.CreateChildView("options") nestedRepeater.DataBind() end if end if end if response.write("<br />") end sub
-
nested repeaters in vb.netAre there any examples out there of how to display hierarchical data by using nested repeater controls using vb.net that don't use a code behind?
-
nested repeaters in vb.netI'm still new to this and I'm not to sure about how to use the code behind. Is there anyway to do it without using one? If there isn't how do you use one.
-
nested repeaters in vb.netIt seems as though the forum has made swiss cheese out of my code. It put the bottom seciton on top and took out all of my web controls....:mad: o well. I hope you can understand it anyway.
-
nested repeaters in vb.netHi, I've been tring to get nested repeaters to work in vb.net for a while now and I can't seem to do it. The data doesnt want to bind to the second repeater, or atleast it does bind but doesnt display. Here is the code that im using: <%@ Import Namespace="System.Data.Odbc" %> <%@ Import Namespace="System.Data" %> sub Page_Load Dim sConnString As String = "Dsn=mysqldb;" & _ "Uid=bigtone78;" & _ "Pwd=" Dim oODBCConnection As New OdbcConnection(sConnString) Dim myInsertQuery As String = "SELECT * FROM questions" Dim myOdbcCommand As New OdbcCommand(myInsertQuery) myOdbcCommand.Connection = oODBCConnection oODBCConnection.Open() questions.DataSource= myOdbcCommand.ExecuteReader() questions.DataBind() myOdbcCommand.Connection.Close() oODBCConnection.Close() end sub sub questions_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs) Handles questions.ItemDataBound if e.item.itemtype = ListItemType.Item or e.item.ItemType = ListItemType.AlternatingItem then Dim sConnString2 As String = "Dsn=mysqldb;" & _ "Uid=bigtone78;" & _ "Pwd=" Dim oODBCConnection2 As New OdbcConnection(sConnString2) Dim SQLstring2 As String = "Select * from options" Dim myOdbcCommand2 As New OdbcCommand(SQLstring2) myOdbcCommand2.Connection = oODBCConnection2 oODBCConnection2.Open() Dim myReader As OdbcDataReader = myOdbcCommand2.ExecuteReader() Dim nestedRepeater as Repeater = e.item.FindControl("opts") if (Not nestedrepeater Is Nothing) then nestedRepeater.DataSource = myReader nestedRepeater.DataBind() end if myOdbcCommand2.Connection.Close() oODBCConnection2.Close() end if end sub
id
question
<%#Container.DataItem("id")%>
<%#Container.DataItem("question")%>
<%#Container.DataItem("opt")%>