Hello. I've been having a lot of trouble with a user control that I've been trying to create. I'm trying to make a dynamic hierarchical menu that displays a submenu whenever a main category item is clicked. I've gone through many incarnations of this, with DataLists, Repeaters and hidden Panels, and nothing's worked.
Right now, I'm trying to run the method that will display my submenu panel and I'm getting the following error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS1518: Expected class, delegate, enum, interface, or struct
Source Error:
Line 111: #line hidden
Line 112:
Line 113: public leftnav_ascx() {
Line 114: if ((ASP.leftnav_ascx.__initialized == false)) {
Line 115: ASP.leftnav_ascx.__initialized = true;
Source File: c:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Temporary ASP.NET Files\root\2135a508\8d69a834\qewupd-o.0.cs Line: 113
I've read some of the forums, and I know that this message is usually produced when the type of method is not specified, however I've made sure that that is not the case in my code. Could someone take a look at it and tell me if there's something else that I'm doing wrong?
Thanks.
<%@ Control Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OleDb" %>
<script runat="server">
protected void Page_Load(Object Src, EventArgs e) {
if (!Page.IsPostBack) {
OleDbConnection myConnection;
OleDbDataAdapter myCommand;
pnlSubNav.Visible = false;
myConnection = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("/work/boc/bocxp-02084/db/bocxp-02084.mdb") + ";Persist Security Info=false;");
myCommand = new OleDbDataAdapter("SELECT catID, catName FROM cat WHERE catOrder > 0 ORDER BY catOrder ASC", myConnection);
DataSet dsLeftNav = new DataSet();
myCommand.Fill(dsLeftNav, "Categories");
ddlLeftNav.DataSource=dsLeftNav.Tables["Categories"].DefaultView;
ddlLeftNav.DataBind();
}
}
protected void SubNavSelect(Object sender, EventArgs e) {
OleDbConnection myConnection;
OleDbDataAdapter myCommand;
myConnection = new OleDbConnection("Provider=Microsoft.Jet.OleDb.4.0;Data Source=" + Server.MapPath("/work/boc/bocxp-02084/db/bocxp-02084.mdb") + ";Persist Security Info=false;");
myCommand = new OleDbDataAdapter("SELECT subcat.subcatID, subcat.catID, subcat.subcatName, cat.catName FROM subcat WHERE subcat.subcatID=" + ddlLeftNav.SelectedItem.Value + " LEFT JOIN cat ON subcat.catID=cat.catID ORDER BY subcat.subcatOrder ASC", myConnection);
DataSet dsSubCat = new DataSet();
myCommand.Fill(dsSubCat, "SubCategories");
rptSubNav.DataSource = dsSubCat.Tables["SubCategories"].DefultView;
rptSubNav.DataBind();
pnlSubNav.Visible = true;
}
}
</script>
<table width="150" cellpadding="0" cellspacing="0" border="0">
<tr><td>
<asp:DropDownList id="ddlLeftNav" AutoPostBack="true" DataTextField="catName" DataValueField="catID" OnSelectedIndexChanged="SubNavSelect" runat="server">
</asp:DropDownList>
</td></tr>
<asp:panel id="pnlSubNav" runat="server">
<tr><td align="center">
<asp:Repeater id="rptSubNav" runat="server">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "subcatName") %><br/>
</ItemTemplate>
</asp:Repeater>
</td></tr>
</asp:panel>
<tr><td align="center">
<br/><img src="/work/boc/bocxp-02084/images/ads/PoweredByASPNET.gif" alt="Powered by ASP.Net" border="0"/>
</td></tr>
</table>