We help IT Professionals succeed at work.

DropdownList Gridview Filter Not Working

kiannack55
kiannack55 used Ask the Experts™
on
I am using a dropdownlist to filter the contents of a gridview in c#. When a new item is selected in the dropdownlist nothing happens.

Thanks in advance
stsddl = new DropDownList();
                stsddl.ID = "sts1";
                stsddl.Items.Add(new ListItem("Open"));
                stsddl.Items.Add(new ListItem("Closed"));
                stsddl.AutoPostBack = true;
            IssuesPanel.Controls.Add(stsddl);

		ControlParameter cp = new ControlParameter();
                cp.ControlID = stsddl.ID.ToString();
                cp.PropertyName = "SelectedValue";
                cp.Name = "Status";
                cp.Type = TypeCode.String;
                cp.ConvertEmptyStringToNull = false;
                sds.FilterParameters.Add(cp);
		  sds.ID = "sds1";
                sds.FilterParameters.Clear();
                sds.SelectParameters.Clear();
                sds.SelectParameters.Add("sid", sid);
		    sds.FilterExpression = "Status LIKE '" + stsddl.SelectedValue + "'";

		GridView gv4 = new GridView();
                gv4.DataSource = sds;
                gv4.DataBind();             
            IssuesPanel.Controls.Add(gv4);

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Top Expert 2013
Commented:
I think it's related to events not firing due to adding your controls dynamically. Check this one or search for events with dynamic controls.