Solved

datalist not showing generic list of strings

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

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 60

Expert Comment

by:Kevin Cross
ID: 22609322
Great!

Glad you solved it.

Regards,
Kevin
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
I have developed many web applications with asp & asp.net and to add and use a dropdownlist was always a very simple task, but with the new asp.net, setting the value is a bit tricky and its not similar to the old traditional method. So in this a…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

730 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