Newbie: ArrayList and DataList problems.

  • Thread starter Thread starter John Spiegel
  • Start date Start date
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
 
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
 
Back
Top