问一个DROPDOWNLIST的问题,实现下拉进行过滤
我的GRIDVIEW里面有一个DROPDOWNLIST,是在HEADER里面,我想实现通过下拉选择进行过滤。以下是源码://绑定商品名称
DropDownList ddlname = (DropDownList)GridView1.HeaderRow.FindControl("ddlstkname");
if (ddlname != null)
{
string sql2 = "select ID,stkname from tblstock order by id asc";
SqlCommand cmd2 = new SqlCommand(sql2, conn);
SqlDataAdapter adp2 = new SqlDataAdapter(cmd2);
DataSet ds2 = new DataSet();
adp2.Fill(ds2, "tblstock2");
ddlname.DataSource = ds2.Tables["tblstock2"].DefaultView;
ddlname.DataTextField = "stkname";
ddlname.DataValueField = "ID";
ddlname.DataBind();
ddlname.Items.Insert(0, new ListItem("商品过滤", "0"));
//ddlname.SelectedIndex = 0;
}
现在实现的是:选择数据库里面的数据都能实现,下拉哪个GRIDVIEW就显示哪个。
问题是:当我选择“商品过滤”时,没有反应,ddlstkname 的 AutoPostBack 为TRUE,请问如何实现 ?