数组绑定到DataList示例

Default.aspx:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!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">
    <title>数组绑定到DataList示例-Mzwu.Com</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:DataList ID="DataList1" runat="server">
            <ItemTemplate>
                <%# Container.DataItem %>
            </ItemTemplate>
        </asp:DataList>
    </div>
    </form>
</body>
</html>

Default.aspx.cs:
public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        string[] list = new string[6] { "aaa", "bbb", "ccc", "ddd", "eee", "fff" };

        DataList1.DataSource = list;
        DataList1.DataBind();
    }
}


评论: 0 | 引用: 0 | 查看次数: 4426
发表评论
登录后再发表评论!