asp.net中如何根据不同的按钮,执行不同的sql语句,进行分页
我的代码只能执行一条sql语句,有没有办法实现按不同的按钮,执行不同的语句(多个按钮,一个GridView)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();