none
datalist related to List<> RRS feed

All replies

  • I think this is the example you need:

    just use

    <ItemTemplate>
           
    Capital: <%# Container.DataItem %> <br />
            </
    ItemTemplate>

    Full page code

     

    <%@ Page Language="C#" AutoEventWireup="true" %>
    <script runat="server" language="C#">
        protected void Page_Load(object sender, EventArgs e)
        {
            System.Collections.Generic.List<string> list = new System.Collections.Generic.List<string>();
            list.Add("Sofia");
            list.Add("Paris");
            list.Add("London");
            list.Add("Rome");
            dl1.DataSource = list;
            dl1.DataBind();
        }
        
    </script>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
    </head>
    <body>
        <form id="form1" runat="server">
        <asp:DataList ID="dl1" runat="server">
            <HeaderTemplate>
                List of capitals:
            </HeaderTemplate>
            <ItemTemplate>
            Capital: <%# Container.DataItem %> <br />
            </ItemTemplate>
        </asp:DataList>
        </form>
    </body>
    </html>
    

     

    Hope this helps:

    Tuesday, January 29, 2008 9:13 PM
  • thank you very much for your help
    Wednesday, January 30, 2008 12:23 PM