asp.net查询后又进行其它查询时,分页翻页出错(不能根据不同的查询语句进行变化)
我的代码是这个样子的,要是能够判断按的是哪个按钮,而进行不同的sql语句就好了,但我不知道代码怎么写 protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
string cond = " and 进仓编号 like " + "'%" + TextBox1.Text.ToString() + "%'";
string sql = "select distinct(进仓编号),仓库 from ck_进仓主表 zb inner join ck_进仓明细 mx on zb.进仓主键=mx.进仓主键" + cond;
string connString = ConfigurationManager.ConnectionStrings["DepotConnectionString"].ToString();
SqlConnection conn = new SqlConnection(connString);
SqlDataAdapter da = new SqlDataAdapter();
da.SelectCommand = new SqlCommand(sql, conn);
DataSet ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.AllowPaging = true;
GridView1.PageSize = 20;
GridView1.DataBind();
conn.Close();