前台界面
<table class="pure-table pure-table-bordered table-hover" width="100%">
<tr>
<td style=" width:10px;">
<input name="chkAll" type="checkbox" id="selectAll" /></td>
<td>考场号</td>
<td>考场名</td>
<td>座位数</td>
<td>状态</td>
</tr>
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<tr>
<td style=" width:10px;"><input name="chkSon" type="checkbox" id="cbx" runat="server" class="cbx" />
<td>
<asp:Label ID="Lab_kch" runat="server" Text='<%#Eval("kcxx_kch") %>'></asp:Label></td>
<td><%#Eval("kcxx_kcm") %></td>
<td><%#Eval("kcxx_zws") %></td>
<td><%#Eval("kcxx_sffp") %></td>
</tr>
</ItemTemplate>
</asp:Repeater>
<tr>
<td colspan="5" align="right">
<webdiyer:AspNetPager ID="AspNetPager1" runat="server" FirstPageText="首页"
LastPageText="尾页" PagingButtonSpacing="10px" ShowPageIndex="true"
NextPageText="下一页" PrevPageText="上一页" ShowCustomInfoSection="right"
CustomInfoHTML="第%CurrentPageIndex%页/共%PageCount%页"
SubmitButtonText="GO" TextAfterPageIndexBox="页" TextBeforePageIndexBox="转到"
UrlPaging="true" CustomInfoSectionWidth="15%" CustomInfoTextAlign="Right"
OnPageChanging="AspNetPager1_pageChanged" CssClass="google-maps" PageSize="8" AlwaysShow="true">
</webdiyer:AspNetPager>
</td>
</tr>
</table>
后台操作:
public partial class JWC_fpkc : System.Web.UI.Page
{
private const string sql_search_rs = "select COUNT(*)from bmxx where bmxx_ztdm=@ztdm and bmxx_bkzyh=@bkzyh";
private const string sql_search_kcxx = "select kcxx_kch,kcxx_kcm,kcxx_zws,kcxx_sffp=case kcxx_sffp when 0 then'未分配' when 1 then '已分配' end from kcxx";
protected void Page_Load(object sender, EventArgs e)
{
if(!IsPostBack)
{
AspNetPager1.RecordCount = RecoudCount();
}
}
/// <summary>
/// 获得所报考专业人数
/// </summary>
private void BD_lab()
{
SqlParameter[] spa={
new SqlParameter("@ztdm",SqlDbType.VarChar,2),
new SqlParameter("@bkzyh",SqlDbType.VarChar,2)};
spa[0].Value = "4";
spa[1].Value = Drop_zy.SelectedValue.ToString();
string i = SqlHelper.ExecuteScalar(SqlHelper.sqlcon, CommandType.Text, sql_search_rs, spa).ToString();
Lab_rs.Text = i;
}
protected void Drop_zy_SelectedIndexChanged(object sender, EventArgs e)
{
BD_lab();
}
protected void LinkCX_Click(object sender, EventArgs e)
{
}
/// <summary>
/// 绑定考场信息
/// </summary>
private void BD_kcxx()
{
SqlParameter[] spa ={
new SqlParameter("@pagesize",AspNetPager1.PageSize),
new SqlParameter("@pageindex",AspNetPager1.CurrentPageIndex),
new SqlParameter("@docount",0)};
DataSet ds = SqlHelper.ExecuteDataset(SqlHelper.sqlcon, CommandType.StoredProcedure, "Stor_kcxx", spa);
Repeater1.DataSource = ds.Tables[0];
Repeater1.DataBind();
}
/// <summary>
/// 返回总页数
/// </summary>
/// <returns></returns>
private int RecoudCount()
{
return (int)SqlHelper.ExecuteScalar(SqlHelper.sqlcon,CommandType.Text,"select count(*) from kcxx");
}
//换页事件
protected void AspNetPager1_pageChanged(object sender, Wuqi.Webdiyer.PageChangingEventArgs e)
{
AspNetPager1.CurrentPageIndex = e.NewPageIndex;
BD_kcxx();
}
}
}
/*
存储过程
create procedure [dbo].[Stor_kcxx]
(@pagesize int,
@pageindex int,
@docount bit)
as
if(@docount=1)
select count(*) from kcxx
else
begin
with temptbl as (
SELECT ROW_NUMBER() OVER (ORDER BY kcxx_kch asc)AS Row, O.kcxx_kch as kcxx_kch,O.kcxx_kcm as kcxx_kcm,O.kcxx_zws as kcxx_zws,O.kcxx_sffp as kcxx_sffp from kcxx O )
SELECT * FROM temptbl where Row between (@pageindex-1)*@pagesize+1 and (@pageindex-1)*@pagesize+@pagesize
end
*/