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();
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>
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Great!
Glad you solved it.
Regards,
Kevin
Glad you solved it.
Regards,
Kevin
dlDSN.DataSource = list;
Here is an example using ArrayList:
http://www.mikepope.com/blog/AddComment.aspx?blogid=1419