Newbie: ArrayList and DataList problems.

J

John Spiegel

Hi All,

I'm working on a page that essentially loops through a table with a
DataReader, does stuff then lists the outcomes. It records the outcomes in
an ArrayList.

I'm having trouble defining a DataList that uses the ArrayList as the data
source. Here's what I've got so far:

<asp:DataList id="dlOutcome" runat-server RepeatColumns=1
RepeatDirection=Vertical>
<ItemTemplate>
<%# DataBinder.Eval( Container.DataItem, alOutcome) %>
</ItemTemplate>
<asp:DataList>


I get a compilation error of CS0117: 'System.Web.UI.Control' does not
contain a definition for 'DataItem'. The examples I can find all use
variations on pulling data from a table but also indicate that an ArrayList
is also a valid data source. Can anyone see what I'm messing up or
post/direct to an example of using an array list as a data source?

Also on a related topic, can ArrayLists be multidimensional? I'm not seeing
how to do so and would think it would be nice to lay out multiple columns in
a DataList.

TIA,

John
 
J

John Spiegel

As usual, I find at least one stupid error shortly after posting. The
DataList had "runat-server" instead of "runat=server". I'm still having
trouble, just a different error: The name 'alOutcome' does not exist in the
class or namespace 'ASP.SendMailFileDriven_aspx'

I have the ArrayList created the Page_Load as follows...

protected void Page_Load(Object src, EventArgs e)
{
if (!IsPostBack)
{
// Snipped: Connection and setup of "reader", a datareader
ArrayList alOutcome = new ArrayList();
while (reader.Read())
{
alOutcome.Add( (string)reader["Cust_ID"] );
alOutcome.Add( (string)reader["Name"] );
alOutcome.Add( "SUCESS" );
}
reader.Close();

dlOutcome.DataSource = alOutcome;
dlOutcome.DataBind();
conn.Dispose();
}
}

....

<asp:DataList id="dlOutcome" RepeatDirection="Vertical" RepeatColumns="1"
runat=server>
<ItemTemplate>
<%# DataBinder.Eval( Container.DataItem, alOutcome) %>
</ItemTemplate>
</asp:DataList>


Thanks, again for any guidance!

- John
 

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

Similar Threads

Bind ArrayList to DataList 4
Question about DataList 1
Errors with DataList 0
Arraylist and Datalist 0
Set Datalist height dynamically 3
DataList Close SelectedItem 0
datalist and separatorTemplate 0
DataList 2

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top