Errors with DataList

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&param="; // just an example :D
}

}

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:DataList>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,072
Latest member
trafficcone

Latest Threads

Top