Repeater绑定实例

<%@ Page language="c#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.SqlClient" %>

<script runat="server">
void Page_Load(Object sender, EventArgs e) { SqlConnection cnn = new SqlConnection("server=(local);database=pubs;Integrated Security=SSPI"); SqlDataAdapter da = new SqlDataAdapter("select * from authors", cnn); DataSet ds = new DataSet(); da.Fill(ds, "authors"); Repeater1.DataSource = ds.Tables["authors"]; Repeater1.DataBind(); } </script>
<html>
<body>
 <form id="WebForm2" method="post" runat="server">
 <asp:Repeater id="Repeater1" runat="server">
 <ItemTemplate>
 <%# DataBinder.Eval(Container.DataItem,"au_id") %><br>
 </ItemTemplate>
 </asp:Repeater>
 </form>
</body>
</html>

原文链接: http://blog.csdn.net/mypc2010/article/details/7953607

你可能感兴趣的:(Repeater绑定实例)