前台显示代码
- <pre name="code" class="csharp"><asp:Repeater ID="Repeater1" runat="server">
- <HeaderTemplate>
- <table style="width: 100%; text-align: center; height: 102px; font-size: small;" align="center"
- rules="all">
- <tr>
- <td align="center" rowspan="2" style="width: 48px">
- 姓名</td>
- <td colspan="3">
- 星期一</td>
- <td colspan="3">
- 星期二</td>
- <td colspan="3">
- 星期三</td>
- <td colspan="3">
- 星期四</td>
- <td colspan="3">
- 星期五</td>
- <td colspan="3">
- 星期六</td>
- <td colspan="3">
- 星期日</td>
- </tr>
- <tr>
- <td>
- 上午</td>
- <td>
- 下午</td>
- <td>
- 晚上</td>
- <td>
- 上午</td>
- <td>
- 下午</td>
- <td>
- 晚上</td>
- <td>
- 上午</td>
- <td>
- 下午</td>
- <td>
- 晚上</td>
- <td>
- 上午</td>
- <td>
- 下午</td>
- <td>
- 晚上</td>
- <td>
- 上午</td>
- <td>
- 下午</td>
- <td>
- 晚上</td>
- <td>
- 上午</td>
- <td>
- 下午</td>
- <td>
- 晚上</td>
- <td>
- 上午</td>
- <td>
- 下午</td>
- <td>
- 晚上</td>
- </tr>
- </HeaderTemplate>
- <ItemTemplate>
- <tr>
- <td><asp:Label runat="server" ID="Label1" Text='<%# Eval("MemberName") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label2" Text='<%# Eval("MonM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label3" Text='<%# Eval("MonA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label4" Text='<%# Eval("MonN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label5" Text='<%# Eval("TueM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label6" Text='<%# Eval("TueA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label7" Text='<%# Eval("TueN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label8" Text='<%# Eval("WenM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label9" Text='<%# Eval("WenA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label10" Text='<%# Eval("WenN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label11" Text='<%# Eval("ThurM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label12" Text='<%# Eval("ThurA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label13" Text='<%# Eval("ThurN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label14" Text='<%# Eval("FriM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label15" Text='<%# Eval("FriA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label16" Text='<%# Eval("FriN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label17" Text='<%# Eval("SatM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label18" Text='<%# Eval("SatA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label19" Text='<%# Eval("SatN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label20" Text='<%# Eval("SunM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label21" Text='<%# Eval("SunA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label22" Text='<%# Eval("SunN") %>'></asp:Label></td>
- </tr>
- </ItemTemplate>
- <AlternatingItemTemplate>
- <tr>
- <td><asp:Label runat="server" ID="Label1" Text='<%# Eval("MemberName") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label2" Text='<%# Eval("MonM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label3" Text='<%# Eval("MonA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label4" Text='<%# Eval("MonN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label5" Text='<%# Eval("TueM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label6" Text='<%# Eval("TueA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label7" Text='<%# Eval("TueN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label8" Text='<%# Eval("WenM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label9" Text='<%# Eval("WenA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label10" Text='<%# Eval("WenN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label11" Text='<%# Eval("ThurM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label12" Text='<%# Eval("ThurA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label13" Text='<%# Eval("ThurN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label14" Text='<%# Eval("FriM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label15" Text='<%# Eval("FriA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label16" Text='<%# Eval("FriN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label17" Text='<%# Eval("SatM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label18" Text='<%# Eval("SatA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label19" Text='<%# Eval("SatN") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label20" Text='<%# Eval("SunM") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label21" Text='<%# Eval("SunA") %>'></asp:Label></td>
- <td><asp:Label runat="server" ID="Label22" Text='<%# Eval("SunN") %>'></asp:Label></td>
- </tr>
- </AlternatingItemTemplate>
- <FooterTemplate>
- <tr><td colspan="22"><div align="left" style="font-family: 黑体; font-size: small">备注:符号“○”表示有课</div></td></tr>
- </table>
- </FooterTemplate>
- </asp:Repeater>
- <table>
- <tr>
- <td align="center">
- <asp:LinkButton ID="lbtnFirstPage" runat="server" OnClick="lbtnFirstPage_Click">页首</asp:LinkButton>
- <asp:LinkButton ID="lbtnpritPage" runat="server" OnClick="lbtnpritPage_Click">上一页</asp:LinkButton>
- <asp:LinkButton ID="lbtnNextPage" runat="server" OnClick="lbtnNextPage_Click">下一页</asp:LinkButton>
- <asp:LinkButton ID="lbtnDownPage" runat="server" OnClick="lbtnDownPage_Click">页尾</asp:LinkButton><br />
- 第<asp:Label ID="labPage" runat="server" Text="Label"></asp:Label>页/共<asp:Label ID="LabCountPage" runat="server" Text="Label"></asp:Label>页
- </td>
- </tr>
- </table>
- </pre>
- <pre></pre>
- <h1><a name="t1"></a>后台控制分页代码<br>
- </h1>
- <p></p><pre name="code" class="csharp">//Repeater分页控制显示方法
- public void contrlRepeater()
- {
- DataTable dt = '连接数据库并查询'
- PagedDataSource pds = new PagedDataSource();
- pds.DataSource = dt.DefaultView;
- pds.AllowPaging = true;
- pds.PageSize = 2;
- pds.CurrentPageIndex = Convert.ToInt32(this.labPage.Text) - 1;
- Repeater1.DataSource = pds;
- LabCountPage.Text = pds.PageCount.ToString();
- labPage.Text = (pds.CurrentPageIndex + 1).ToString();
- this.lbtnpritPage.Enabled = true;
- this.lbtnFirstPage.Enabled = true;
- this.lbtnNextPage.Enabled = true;
- this.lbtnDownPage.Enabled = true;
- if(pds.CurrentPageIndex<1)
- {
- this.lbtnpritPage.Enabled = false;
- this.lbtnFirstPage.Enabled = false;
- }
- if (pds.CurrentPageIndex == pds.PageCount-1)
- {
- this.lbtnNextPage.Enabled = false;
- this.lbtnDownPage.Enabled = false;
- }
- Repeater1.DataBind();
- }
- protected void lbtnpritPage_Click(object sender, EventArgs e)
- {
- this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) - 1);
- this.contrlRepeater();
- }
- protected void lbtnFirstPage_Click(object sender, EventArgs e)
- {
- this.labPage.Text = "1";
- this.contrlRepeater();
- }
- protected void lbtnDownPage_Click(object sender, EventArgs e)
- {
- this.labPage.Text =this.LabCountPage.Text;
- this.contrlRepeater();
- }
- protected void lbtnNextPage_Click(object sender, EventArgs e)
- {
- this.labPage.Text = Convert.ToString(Convert.ToInt32(labPage.Text) + 1);
- this.contrlRepeater();
- }</pre><br>
- <br>
- <p></p>
- <pre name="code" class="csharp">
- </pre>
- <div style="padding-top:20px">
- <p style="font-size:12px;">版权声明:本文为博主原创文章,未经博主允许不得转载。</p>
- </div>