Link to home
Start Free TrialLog in
Avatar of jentel2
jentel2

asked on

datalist not showing generic list of strings

Using .NET 3.5.

I have a datalist in a web page and I am trying to databind it to a List<string> but nothing is showing. The html source is showing an empty html table.

I am doing something simple. What am I missing?
  List<string> list = new List<string>();
            list.Add("test");
            dlDSN.DataSource = list.ToArray();
//          dlDSN.DataSource = list;
            dlDSN.DataBind();
Result html:
 
<TABLE id=dlDSN style="BORDER-COLLAPSE: collapse" cellSpacing=0 border=0>
<TBODY>
<TR>
<TD></TD></TR>
<TR>
<TD></TD></TR></TBODY></TABLE>

Open in new window

Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

From my understanding, this is the proper approach (the one you have commented):
dlDSN.DataSource = list;

Here is an example using ArrayList:
http://www.mikepope.com/blog/AddComment.aspx?blogid=1419
Can you show how you have created your <asp:DataList> element. Have you turned on the Auto-Generate columns or created an ItemTemplate for your data?
ASKER CERTIFIED SOLUTION
Avatar of jentel2
jentel2

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Great!

Glad you solved it.

Regards,
Kevin