.net 简单循环

页面代码

<asp:Repeater ID="Repeater1" runat="server">
        <ItemTemplate>
       <%#Eval("CategoryID")%>&nbsp<%#Eval("CategoryName")%><br>
       </ItemTemplate>
     </asp:Repeater>

类代码

string connectionString = "Data Source=.\\SQLEXPRESS;AttachDbFilename=\"C:\\SQL Server 2000 Sample Databases\\NORTHWND.MDF\";Integrated Security=True;Connect Timeout=30;User Instance=True";
类代码
DataTable dt = DBHelper.GetDataSet("select * from Categories");
            Repeater1.DataSource = dt;
            Repeater1.DataBind();

你可能感兴趣的:(.net 简单循环)