Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

List as DataSource for DataList

All Types implement IEnumerable interface could be used for a DataSource of a DataList. For example List. But what we will write for the data bound expression in ItemTemplate?

List<int> myList = new List<int>();
for(int i=0; i<10; i++)
   myList.Add(i);

myDataList.DataSource = myList;

...
<ItemTemplate>
<asp:TextBox ID="myTextBox" runat="server" Text='<%# Bind(???) %>' />
</ItemTemplate>
like image 461
Sevina Avatar asked Dec 07 '09 18:12

Sevina


1 Answers

Try this:

<%# Container.DataItem.ToString() %>
like image 96
dl. Avatar answered Oct 17 '22 21:10

dl.