gridview查询后分页 点下一页之后数据不正确
显示的是原来没有查询的数据,要实现的是按班级查找//绑定GridViewprivatevoidDataBind(){DataTabledt=GVBind();string...
显示的是原来没有查询的数据,要实现的是按班级查找
//绑定GridView
private void DataBind()
{
DataTable dt = GVBind();
string SortDirection = this.gv_Reward.Attributes["SortDirection"].ToString();
string SortExpression = this.gv_Reward.Attributes["SortExpression"].ToString();
dt.DefaultView.Sort = string.Format("{0} {1}", SortExpression, SortDirection);
this.gv_Reward.DataSource = dt;
this.gv_Reward.DataBind();
}
// 按班级查询
private void ClassName()
{
String sqlstr;
SqlParameter[] parms;
String keybj = ddl_class.SelectedValue;
sqlstr = "select * from Reward where Rclass=@class";
parms = new SqlParameter[]
{
new SqlParameter("@class", System.Data.SqlDbType.NVarChar, 50),
};
parms[0].Value = keybj;
DataSet dsbj = SqlHelper.ExecuteDataSet(sqlstr, parms);
gv_Reward.DataSource = dsbj.Tables[0].DefaultView;
gv_Reward.DataBind();
}
//gridview分页
protected void gv_Reward_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
try
{
if (IsPostBack)
{
gv_Reward.PageIndex = e.NewPageIndex;
GVBind();
TextBox tb = (TextBox)gv_Reward.BottomPagerRow.FindControl("inPageNum");
tb.Text = (gv_Reward.PageIndex + 1).ToString();
//GVBind();
}
}
catch
{
}
}
根据条件查询之后应该只显示条件的结果!为什么点击下页之后数据又是加载时后的数据 展开
//绑定GridView
private void DataBind()
{
DataTable dt = GVBind();
string SortDirection = this.gv_Reward.Attributes["SortDirection"].ToString();
string SortExpression = this.gv_Reward.Attributes["SortExpression"].ToString();
dt.DefaultView.Sort = string.Format("{0} {1}", SortExpression, SortDirection);
this.gv_Reward.DataSource = dt;
this.gv_Reward.DataBind();
}
// 按班级查询
private void ClassName()
{
String sqlstr;
SqlParameter[] parms;
String keybj = ddl_class.SelectedValue;
sqlstr = "select * from Reward where Rclass=@class";
parms = new SqlParameter[]
{
new SqlParameter("@class", System.Data.SqlDbType.NVarChar, 50),
};
parms[0].Value = keybj;
DataSet dsbj = SqlHelper.ExecuteDataSet(sqlstr, parms);
gv_Reward.DataSource = dsbj.Tables[0].DefaultView;
gv_Reward.DataBind();
}
//gridview分页
protected void gv_Reward_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
try
{
if (IsPostBack)
{
gv_Reward.PageIndex = e.NewPageIndex;
GVBind();
TextBox tb = (TextBox)gv_Reward.BottomPagerRow.FindControl("inPageNum");
tb.Text = (gv_Reward.PageIndex + 1).ToString();
//GVBind();
}
}
catch
{
}
}
根据条件查询之后应该只显示条件的结果!为什么点击下页之后数据又是加载时后的数据 展开
1个回答
2015-08-05
展开全部
PrintPreviewDialog pPDlg;
exec_prefix='吵袭NONE'PACKAGE='libevent'
PACKAGE_BUGREPORT=''敬凳
PACKAGE_NAME='升稿兄'
PACKAGE_STRING=''
PACKAGE_TARNAME=''
PACKAGE_URL=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
exec_prefix='吵袭NONE'PACKAGE='libevent'
PACKAGE_BUGREPORT=''敬凳
PACKAGE_NAME='升稿兄'
PACKAGE_STRING=''
PACKAGE_TARNAME=''
PACKAGE_URL=''
PACKAGE_VERSION=''
PATH_SEPARATOR=':'
追问
(⊙o⊙)…额,本人小白,这个代码加到哪==
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询