nested repeaters in vb.net
-
Hi, 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")%>
-
Hi, 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")%>
-
Hi, 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")%>
Your question really belongs in the ASP.NET Forum. But for an example of this, see HOW TO: Display Hierarchical Data by Using Nested Repeater Controls and Visual Basic .NET[^] on MSDN. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
Your question really belongs in the ASP.NET Forum. But for an example of this, see HOW TO: Display Hierarchical Data by Using Nested Repeater Controls and Visual Basic .NET[^] on MSDN. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
I'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.
You really should pick up a book on ASP.NET. It'll clear all this up including basic concepts like code-behind. Code-behind is exactly like a Windows Form. The controls and visuals are in one file and the code that manipulates them are in another, the code-behind page. To answer your question, no, there is no way to do this without the code. There is no trick to "using" a code behind page. When you create an ASP.NET page, two files are created. One for the visuals and HTML, the .aspx file, and the code that controls them, the .aspx.vb file. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome