Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 2nd, 2007, 08:31 AM
Registered User
 
Join Date: Feb 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Stricken
Default Nesting Repeater controls

I am trying to pull data from my database into two repeaters for a forum system. At the moment i have not had time to relate the two tables in any way because I can't get the two repeaters to display. Here is my code:

Code:
<%@ Page Language="VB" Debug="true" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.Odbc" %>
<%@ Import Namespace="MySql.Data.MySqlClient" %>
<%@ Import Namespace="MySql.Data" %>
<%@ Import Namespace="MySql" %>

<script runat="server">

sub Page_Load
    dim connstr as new MySqlConnection("blahblahblah no errors here")

    dim conn as MySqlCommand

    conn = New MySqlCommand("SELECT * from tblforumcats", connstr)
    dim rdr as MySqlDataReader
    connstr.Open()
    rdr = conn.ExecuteReader()

    forumcat.DataSource = rdr
    forumcat.DataBind()

    rdr.Close()

    connstr.Close()

End Sub

Private Sub forumcat_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.RepeaterItemEventArgs)

    dim connstr as new MySqlConnection("blahblahblah no errors here")

    dim conn as MySqlCommand

    conn = New MySqlCommand("SELECT * from tblforums", connstr)
    dim rdr as MySqlDataReader
    connstr.Open()
    rdr = conn.ExecuteReader()

    Dim item As RepeaterItem = e.Item
    If (item.ItemType = ListItemType.Item) OrElse (item.ItemType = ListItemType.AlternatingItem) Then 
        forumnames = CType(item.FindControl("forumnames"), Repeater)
        forumnames.DataSource = rdr
        forumnames.DataBind()
    End If 

    rdr.Close()

    connstr.Close()
End Sub

</script>

<html>
<head>
<meta name="description" content="Saniz Druids Guild Website" />
<meta name="keywords" content="Saniz, Druids, Saniz Druids, Guild, Website, Guild Website, Guild, Wars, Guild Wars, Forum, Forums" />
<META name="verify-v1" content="0wXxe8l6j431OBI5+BuHZo7spsXG6FlUi705pXTn99U=" />
<title>Saniz Druids - Guild Website</title>
<link rel="stylesheet" type="text/css" href="http://www.sanizdruids.com/main.css" />
<link rel="stylesheet" type="text/css" href="http://www.sanizdruids.com/forums/forums.css" />
</head>
<body>

<form runat="server">

<div align="center">
<asp:Image runat="server" ImageUrl="http://www.sanizdruids.com/logo2.jpg" AlternateText="Title Image" /><br />
</div>

<asp:Table runat="server" CellPadding="0" CellSpacing="0" BorderWidth="0" GridLines="none" BackImageUrl="http://www.sanizdruids.com/bg-table.jpg" HorizontalAlign="center" width="800">
    <asp:TableRow>
        <asp:TableCell VAlign="top" ColSpan="2">
        <asp:Image runat="server" ImageUrl="http://www.sanizdruids.com/top-table.jpg" />
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell HorizontalAlign="center" VAlign="top" ColSpan="2">
        <asp:Image runat="server" ImageUrl="header.jpg" id="headerimg" AlternateText="Header Image" />
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell VAlign="top" cssclass="maincontent" width="200">
        [list]
            <li><a href="http://www.sanizdruids.com">Home</a></li>
            <li><a href="http://members.sanizdruids.com">Members</a></li>
            <li><a href="http://forums.sanizdruids.com">Forums</a></li>
            <li><a href="http://www.sanizdruids.com/newbieguide.aspx">Beginner's Guide</a></li>
            <li id="classeslink"><a href="http://www.sanizdruids.com/charclasses.aspx">Character Classes</a></li>
        </ul>
        <br />
        <br />
        [list]
            <li><a href="http://www.sanizdruids.com/contactus.aspx">Contact the Guild</a></li>
            <li><a href="http://www.guildwars.com">Guild Wars Website</a></li>
        </ul>
        </asp:TableCell>
        <asp:TableCell VAlign="top" cssclass="maincontent" width="600">
        <br />
        <div align="center">
        <table class="findextbl" cellpadding="0" cellspacing="0" width="500">
        <asp:Repeater id="forumcat" runat="server">
            <ItemTemplate>
            <tr>
            <td class="findextblhdr"><%#Container.DataItem("catname")%></td>
            </tr>
            <asp:Repeater id="forumnames" runat="server">
                <ItemTemplate>
                <tr>
                <td><%#Container.DataItem("forumname")%></td>
                </tr>
                </ItemTemplate>
            </asp:Repeater>
            </ItemTemplate>
        </asp:Repeater>
        </table>
        <br /><br />
        </div>
        <asp:Image runat="server" ImageUrl="http://www.sanizdruids.com/fpseperator.jpg" Alternatetext="Seperator" />
        </asp:TableCell>
    </asp:TableRow>
    <asp:TableRow>
        <asp:TableCell VAlign="top" ColSpan="2">
        <asp:Image runat="server" ImageUrl="http://www.sanizdruids.com/bottom-table.jpg" />
        </asp:TableCell>
    </asp:TableRow>
</asp:Table>

</div>

</form>

</body>
</html>
The error I get is BC30451: "Name 'forumnames' is not declared". If I add:
Code:
dim forumnames as repeater
in above the code trying to access forumnames, I get no error. The problem is, it doesn't databind to the forumnames repeater.

Any ideas?





Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Child Controls of Nested Repeater... Jayahar ASP.NET 2.0 Professional 3 October 11th, 2007 01:24 PM
Nesting queries??? giffordpinchot Access 0 September 20th, 2006 09:58 AM
How to get inner repeater controls in master detai ceema .NET Framework 2.0 0 September 7th, 2005 01:42 AM
Designing repeater controls badgolfer ASP.NET 1.0 and 1.1 Basics 2 July 18th, 2004 03:24 PM
Subreports nesting svenvandevelde Crystal Reports 2 February 4th, 2004 12:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.