1.创建<asp:SqlDataSource></asp:SqlDataSource>
然后配置数据库的连接方式
2.数据绑定 <asp:Repeater></asp:Repeater>
下面是源码
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString='<%$ ConnectionStrings:zhangyuxiangConnectionString %>' SelectCommand="SELECT * FROM [ehr_EMP]"></asp:SqlDataSource>
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<HeaderTemplate>
<table>
<tr>
<td>用户编号</td>
<td>合同起始时间</td>
</tr>
</table>
</HeaderTemplate>
<ItemTemplate>
<table style="border:2px solid black">
<tr>
<td style="border:2px solid red ;200px;"><%#DataBinder.Eval(Container.DataItem,"PersId") %></td>
<td style="border:2px solid red ;200px;"><%#DataBinder.Eval(Container.DataItem,"Worktime") %></td>
</tr>
</table>
</ItemTemplate>
</asp:Repeater>
页面展示