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?