Quantcast
Viewing all articles
Browse latest Browse all 20

dynamic Filter ( Using multiple drop down list)

I have created a filter which drop down list. I was be able to filter on a single selection and pass the parameter to stored procedure. The problem is that I cant make it where I want to do multiple selection on drop down list and pass these parameters to stored procedure to filter the data. Filter that I have is a dynamic, means that the values that associated with filter are changing based on other drop down list.  Please can anyone help me with that. I am really stuck. here is my code where I can do filter on single selection and pass the parameter to stored procedure:

aspx. file 

</td>
<td style="background-color: #5D7B9D; font-size: medium; font-weight: bold; color: white; width: 100px">Segment:
</td>
<td>
<asp:DropDownList ID="ddlSegments" runat="server" TabIndex="7">
</asp:DropDownList>
</td>

here is my c# file

protected void GetSegments()
{
string str = base.Request.QueryString["OB"];
string str2 = base.Request.QueryString["Alias"];
string cObAlias = "";
if (string.IsNullOrEmpty(str))
{
str = ConfigurationManager.AppSettings["ObjectBroker"];
}
OleDbConnection connection = new OleDbConnection(AmAccess.GetObConnectionString(str, ref cObAlias));
connection.Open();
OleDbCommand selectCommand = new OleDbCommand("clients.dbo.spx_CampaignSegments", connection)
{
CommandType = CommandType.StoredProcedure,
CommandTimeout = connection.ConnectionTimeout
};
selectCommand.Parameters.AddWithValue("@campaignId", this.ddlCampaigns.SelectedItem.Value);
selectCommand.Parameters.AddWithValue("@segment", ConfigurationManager.AppSettings["SegmentField"]);
OleDbDataAdapter adapter = new OleDbDataAdapter(selectCommand);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
this.ddlSegments.DataSource = dataSet.Tables[0];
this.ddlSegments.DataValueField = "STATE";
this.ddlSegments.DataTextField = "STATE";
this.ddlSegments.DataBind();
if (this.CheckConfigurationOn("AllowAllSegments"))
{
ListItem item = new ListItem("All", "All");
this.ddlSegments.Items.Insert(0, item);
item = new ListItem("None", "_x_none_x_");
this.ddlSegments.Items.Insert(0, item);
}
selectCommand.Dispose();
selectCommand = null;
dataSet.Dispose();
dataSet = null;
connection.Close();
}

I will appreciate any assistance 


Viewing all articles
Browse latest Browse all 20

Trending Articles