Solved

datalist not showing generic list of strings

Posted on 2008-09-29
4
812 Views
Last Modified: 2012-05-05
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

0
Comment
Question by:jentel2
  • 2
4 Comments
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 22601429
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
0
 
LVL 10

Expert Comment

by:TKOTC
ID: 22602005
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?
0
 

Accepted Solution

by:
jentel2 earned 0 total points
ID: 22609264
I removed the issue by using a gridview and creating a class.
0
 
LVL 59

Expert Comment

by:Kevin Cross
ID: 22609322
Great!

Glad you solved it.

Regards,
Kevin
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This video discusses moving either the default database or any database to a new volume.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now