Solved

datalist not showing generic list of strings

Posted on 2008-09-29
4
814 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Convert to Hour/minute textbox and compare 3 52
Get Reply from SSIS to intranet site when finished 3 34
Authentication of Web Services 3 53
SQL Login 17 40
I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

920 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

15 Experts available now in Live!

Get 1:1 Help Now