这位兄台 你的page_load事件里面 添加了if(!isPostback)了 吗 如
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridViewTableDataBind();
}
}如果你没加上去 你每次点跳转到""页的时候值都为空 以下是我的分页部分的代码
Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>"
OnClientClick="__doPostBack('lbnFirst','First')" Text="首页">
Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != 0 %>"
Text="上一页">
Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>"
Text="下一页">
Enabled="<%# ((GridView)Container.NamingContainer).PageIndex != (((GridView)Container.NamingContainer).PageCount - 1) %>"
Text="尾页">
到第
页
后台
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
MessListDataBind();
}
}
public void MessListDataBind()
{
gv1.DataSource = BLL.GetMessList.GetMSList();
gv1.DataBind();
}
protected void gv1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
gv1.PageIndex = e.NewPageIndex;
gv1.DataSource = BLL.GetComNew.GetComNews();
gv1.DataBind();
}
protected void LinkPage(object sender, EventArgs e)
{
TextBox tb = (TextBox)gv1.BottomPagerRow.FindControl("inPageNum");
if (tb.Text == null || tb.Text == "")
{
tb.Text = "1";
}
gv1.PageIndex = Convert.ToInt32(tb.Text.ToString());
gv1.DataSource = BLL.GetComNew.GetComNews();
gv1.DataBind();
}