Solved

datalist not showing generic list of strings

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

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…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to use Hyena, from SystemTools Software, to bulk import 100 user accounts from an external text file. View in 1080p for best video quality.

810 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