J
jobo
Hello,
I'm trying to test out a DataList I made but I'm getting a bunch of
errors that say "Expected class, delegate, enum, interface, or struct"
Visual Studio says that those errors are coming from the return type of
my methods (other than the Page_Load method).
Here is my code:
public partial class DefaultChoice : BasePage
{
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
fillSt();
ItemsList.DataBind();
}
}
protected void fillSt()
{
using (FADataBase faDb = DBHelper.GetDatabase(FAUser.Region))
{
string errorString;
//lblMenu.Text = "Branch:";
try
{
if (FAUser.View.Trim() == "1")
{
dt = faDb.gcA(User.Area, out errorString);
ItemsList.DataSource = dt;
}
else
{
dt = faDb.gcB(User.County, out errorString);
ItemsList.DataSource = dt;
}
}
catch
{
}
}
}
protected string GetUrl
{
get
{
return "branches.aspx?type=b¶m="; // just an example
}
}
protected void oidb(object sender, DataListItemEventArgs e)
{
DataListItem item = e.Item;
if (item.ItemType == ListItemType.Item ||
item.ItemType == ListItemType.AlternatingItem)
{
HyperLink hyperLink = (HyperLink)
item.FindControl("hLink");
if (hyperLink != null)
{
hyperLink.NavigateUrl = GetUrl +
dt.Columns["id_organization"].DefaultValue.ToString();
}
}
}
}
I'm also getting an error in my oidb method where it says "identifier
expected" on the line
dt.Columns["id_organization"].DefaultValue.ToString()
Also, I'm trying to cycle through the DataTable so that the DataList
gets a new value each time OnItemDataBound is called. Am I even
grabbing the balues off the DataTable the right way? Thanks.
Here is the front-end:
OnItemDataBound="oidb"
BorderColor="black"
CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Table"
RepeatColumns="3"
BorderStyle="none"
runat="server">
<HeaderStyle BackColor="#aaaadd">
</HeaderStyle>
<AlternatingItemStyle BackColor="Gainsboro">
</AlternatingItemStyle>
<HeaderTemplate>
List of items
</HeaderTemplate>
<ItemTemplate>
<asp:HyperLink ID="hLink" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "FriendlyName") %>'
NavigateUrl='<%# GetUrlExpression %>' />
</ItemTemplate>
</asp
ataList>
I'm trying to test out a DataList I made but I'm getting a bunch of
errors that say "Expected class, delegate, enum, interface, or struct"
Visual Studio says that those errors are coming from the return type of
my methods (other than the Page_Load method).
Here is my code:
public partial class DefaultChoice : BasePage
{
DataTable dt;
protected void Page_Load(object sender, EventArgs e)
{
fillSt();
ItemsList.DataBind();
}
}
protected void fillSt()
{
using (FADataBase faDb = DBHelper.GetDatabase(FAUser.Region))
{
string errorString;
//lblMenu.Text = "Branch:";
try
{
if (FAUser.View.Trim() == "1")
{
dt = faDb.gcA(User.Area, out errorString);
ItemsList.DataSource = dt;
}
else
{
dt = faDb.gcB(User.County, out errorString);
ItemsList.DataSource = dt;
}
}
catch
{
}
}
}
protected string GetUrl
{
get
{
return "branches.aspx?type=b¶m="; // just an example
}
}
protected void oidb(object sender, DataListItemEventArgs e)
{
DataListItem item = e.Item;
if (item.ItemType == ListItemType.Item ||
item.ItemType == ListItemType.AlternatingItem)
{
HyperLink hyperLink = (HyperLink)
item.FindControl("hLink");
if (hyperLink != null)
{
hyperLink.NavigateUrl = GetUrl +
dt.Columns["id_organization"].DefaultValue.ToString();
}
}
}
}
I'm also getting an error in my oidb method where it says "identifier
expected" on the line
dt.Columns["id_organization"].DefaultValue.ToString()
Also, I'm trying to cycle through the DataTable so that the DataList
gets a new value each time OnItemDataBound is called. Am I even
grabbing the balues off the DataTable the right way? Thanks.
Here is the front-end:
OnItemDataBound="oidb"
BorderColor="black"
CellPadding="5"
CellSpacing="5"
RepeatDirection="Vertical"
RepeatLayout="Table"
RepeatColumns="3"
BorderStyle="none"
runat="server">
<HeaderStyle BackColor="#aaaadd">
</HeaderStyle>
<AlternatingItemStyle BackColor="Gainsboro">
</AlternatingItemStyle>
<HeaderTemplate>
List of items
</HeaderTemplate>
<ItemTemplate>
<asp:HyperLink ID="hLink" runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "FriendlyName") %>'
NavigateUrl='<%# GetUrlExpression %>' />
</ItemTemplate>
</asp