<asp:Repeater ID="rpt1" runat="server"> <HeaderTemplate> <table> <tr> <td>ID</td> <tb>次数</tb> </tr> </HeaderTemplate> <ItemTemplate> <tr> <td><%# Eval("A") %></td> <td><%# Eval("B") %></td> </tr> </ItemTemplate> <FooterTemplate> </table> </FooterTemplate> </asp:Repeater>
protected void Button1_Click(object sender, EventArgs e) { string sql = "select * from Table_1"; DataTable dt = SqlHelper.ExecuteDatatable(sql); rpt1.DataSource = dt; rpt1.DataBind(); }