List as DataSource for DataList

All types implement the IEnumerable interface, which can be used for a DataSource DataList. For example, List. But what will we write for a data-related expression in an 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>
+5
source share
1 answer

Try the following:

<%# Container.DataItem.ToString() %>
+6
source

All Articles