如题
this.AspNetPager1.CurrentPageIndex = e.NewPageIndex; 不赋值
调试中this.AspNetPager1.CurrentPageIndex的值一直是1
this.AspNetPager1.CurrentPageIndex = e.NewPageIndex; 不赋值
调试中this.AspNetPager1.CurrentPageIndex的值一直是1
解决方案 »
- 做系统的时候遇到几个问题
- asp.net中的gridview 关于checkbox操作的问题
- 新手问三个问题,来者都有分
- 关于datagrid的databind的问题?谢谢了
- DataGrid中UpdateCommand自定义textbox的问题!!!不能用啊!!!
- 如何点击一个按钮,根据情况决定是否刷新另外一个frame
- 为什么在.cs中响应不到DeleteCommand事件?
- 推荐一款快速开发B/S架构基于.net的信息系统的工具——WebMIS.net 3.0
- Asp.net 的网站需在页面实现以下类似的页面效果,请教解决的思路
- 招聘:.Net程序员
- csdn在搞什么?
- 请问如何解压WINRAR文件?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Bind();
Session.Remove("YXadv");
Session["YXadv"] = "全部代理信息";
}
} public void Bind()
{
AspNetPager1.RecordCount = bllMsg.RGetAllList().Tables[0].Rows.Count;
PagedDataSource pds = new PagedDataSource();
pds.DataSource = bllMsg.RGetAllList().Tables[0].DefaultView;
pds.AllowPaging = true;
pds.PageSize = AspNetPager1.PageSize;
pds.CurrentPageIndex = AspNetPager1.CurrentPageIndex - 1;
RepAll.DataSource = pds;
RepAll.DataBind();
} /// <summary>
/// 翻页
/// </summary>
protected void AspNetPager1_PageChanged(object src, Wuqi.Webdiyer.PageChangedEventArgs e)
{
try
{
this.AspNetPager1.CurrentPageIndex =e.NewPageIndex;
}
catch (Exception)
{
throw;
}//当前索引页
Bind();
}
<%@ Import Namespace="System.Data"%>
<%@Import Namespace="System.Data.SqlClient"%>
<%@Import Namespace="System.Configuration"%>
<%@Register TagPrefix="Webdiyer" Namespace="Wuqi.Webdiyer" Assembly="aspnetpager"%>
<HTML>
<HEAD>
<TITLE>Welcome to Webdiyer.com </TITLE>
<script runat="server">
SqlConnection conn;
SqlCommand cmd;
void Page_Load(object src,EventArgs e)
{
conn=new SqlConnection(ConfigurationSettings.AppSettings["ConnStr"]);
if(!Page.IsPostBack)
{
cmd=new SqlCommand("GetNews",conn);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add("@pageindex",1);
cmd.Parameters.Add("@pagesize",1);
cmd.Parameters.Add("@docount",true);
conn.Open();
pager.RecordCount=(int)cmd.ExecuteScalar();
conn.Close();
BindData();
}
}void BindData()
{
cmd=new SqlCommand("GetNews",conn);
cmd.CommandType=CommandType.StoredProcedure;
cmd.Parameters.Add("@pageindex",pager.CurrentPageIndex);
cmd.Parameters.Add("@pagesize",pager.PageSize);
cmd.Parameters.Add("@docount",false);
conn.Open();
dataGrid1.DataSource=cmd.ExecuteReader();
dataGrid1.DataBind();
conn.Close();
pager.CustomInfoText="记录总数:<font color=\"blue\"><b>"+pager.RecordCount.ToString()+"</b></font>";
pager.CustomInfoText+=" 总页数:<font color=\"blue\"><b>"+pager.PageCount.ToString()+"</b></font>";
pager.CustomInfoText+=" 当前页:<font color=\"red\"><b>"+pager.CurrentPageIndex.ToString()+"</b></font>";
}
void ChangePage(object src,PageChangedEventArgs e)
{
pager.CurrentPageIndex=e.NewPageIndex;
BindData();
}
</script>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="content-type" content="text/html;charset=gb2312">
<META NAME="Generator" CONTENT="EditPlus">
<META NAME="Author" CONTENT="Webdiyer([email protected])">
</HEAD>
<body>
<form runat="server" ID="Form1">
<asp:DataGrid id="dataGrid1" runat="server" /><Webdiyer:AspNetPager id="pager"
runat="server"
PageSize="8"
NumericButtonCount="8"
ShowCustomInfoSection="left"
PagingButtonSpacing="0"
ShowInputBox="always"
CssClass="mypager"
HorizontalAlign="right"
OnPageChanged="ChangePage"
SubmitButtonText="转到"
NumericButtonTextFormatString="[{0}]"/></form>
</body>
</HTML>
BindData中
Rept.DataSource = ds.Tables[0];
Rept.DataBind();
AspNetPager1.RecordCount = count;
AspNetPager1.PageSize = pagesize;
AspNetPager1.CurrentPageIndex = PageIndex;
{
}
private void AspNetPager1_PageChanged(object sender, System.EventArgs e)
{ //页索引改变方法
this.BindData();
}