代码应该是没问题的,我也断点测试过了,CurrentPageIndex赋值过后还是1,有人遇到过这种情况吗?
解决方案 »
- ASP.NET时间问题
- 请问高手:发布后的网站出现这样的错误
- asp.net如何偷另一个网站的图片,并且截取其中一部分,存入数据库
- 如何以table显示dataset中的数据?
- ■■存储过程如何用一个传入的变量去代替一个表名呢???我就是想通过传入不同的变量去操作不同的数据库,这个存储过程应该怎样写????
- web打印问题
- 记录的位置,比较郁闷!!!!大哥们救我啊 ~~~~~~~~~
- 当弹出一个窗体时,有没有办法取消window窗口工具栏上的ie图标,就象show模式对话框一样
- 用vs写静态网页要用DBHelper类来链接数据库吗?
- 请教session的问题
- 关于使用javascript在客户端对输入进行验证的问题
- Gridview 在firefox MyIE 浏览器显示问题
{
get
{
if (ViewState["currentPageIndex"] != null)
{
return Convert.ToInt32(ViewState["currentPageIndex"].ToString());
}
else
{
return 1;
}
}
set
{
ViewState["currentPageIndex"] = value;
}
}
public void BindGridView(int pageIndex)
{
AspNetPager1.CurrentPageIndex = pageIndex;
Label12.Text = AspNetPager1.CurrentPageIndex.ToString();//测试赋值
OleDbDataAdapter da;
Conn().Open();
string choiceString;
AspNetPager1.PageSize = 50;
AspNetPager1.RecordCount = Int32.Parse(GetAllCount().ToString());
choiceString = MakeString(TextBox1, TextBox2, TextBox3, TextBox4,
TextBox5,TextBox6, TextBox7, TextBox8);
da = new OleDbDataAdapter(choiceString, Conn());
DataSet ds = new DataSet();
da.Fill(ds, (pageIndex- 1) * AspNetPager1.PageSize, AspNetPager1.PageSize, "总表");
GridView1.DataSource=ds.Tables[0];
GridView1.DataBind();
AspNetPager1.CustomInfoHTML = "记录总数:<b>" + AspNetPager1.RecordCount.ToString() + "</b>";
AspNetPager1.CustomInfoHTML += " 总页数:<b>" + AspNetPager1.PageCount.ToString() + "</b>";
AspNetPager1.CustomInfoHTML += " 当前页:<font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>";
}
我在Page_Load(object sender, EventArgs e)里面写
if (!IsPostBack)
{
BindGridView(2);
}Label12.Text 的值都为1!
public void BindGridView(int pageIndex)
{
AspNetPager1.RecordCount = Int32.Parse(GetAllCount().ToString());//这句放头上
OleDbDataAdapter da;
Conn().Open();
string choiceString;
AspNetPager1.PageSize = 50;
choiceString = MakeString(TextBox1, TextBox2, TextBox3, TextBox4,
TextBox5,TextBox6, TextBox7, TextBox8);
da = new OleDbDataAdapter(choiceString, Conn());
DataSet ds = new DataSet();
da.Fill(ds, (pageIndex- 1) * AspNetPager1.PageSize, AspNetPager1.PageSize, "总表");
GridView1.DataSource=ds.Tables[0];
GridView1.DataBind();
AspNetPager1.CustomInfoHTML = "记录总数:<b>" + AspNetPager1.RecordCount.ToString() + "</b>";
AspNetPager1.CustomInfoHTML += " 总页数:<b>" + AspNetPager1.PageCount.ToString() + "</b>";
AspNetPager1.CustomInfoHTML += " 当前页:<font color=\"red\"><b>" + AspNetPager1.CurrentPageIndex.ToString() + "</b></font>";
AspNetPager1.CurrentPageIndex = pageIndex;
Label12.Text = AspNetPager1.CurrentPageIndex.ToString();//测试赋值
}
还有如果本身我总共的PAGE只有一页怎么办?你设个2有什么用?
if(Session["flag"]==null)
{
pageindex=1;
Session["flag"]=1;
}
else
pageindex=AspNetPager1.CurrentPageIndex;
window.opener.refresh();
parent page:
function refresh()
{
document.getElementById('<%=hidValue.ClientID%>')='refresh';
document.forms[0].submit();
}cs
if(!Page.isPostBack)
{
//...
}
else
{
if(hidValue.Value=="refresh")
{
BindData();
hidValue.Value="";
}
}
赋非“1”值之后还是为1,我郁闷啊。
{
if (!IsPostBack)
{
if (Session["pageIndex"] == null)
{
BindGridView(1);
}
if(Session["pageIndex"]!=null)
{
string pageIndex = Session["pageIndex"].ToString();
int index = Int32.Parse(pageIndex);
BindGridView(index);
Session.Remove("pageIndex");
}
}
}