Quantcast
Channel: dynamic Filter ( Using multiple drop down list)
Viewing all articles
Browse latest Browse all 20

Re: dynamic Filter ( Using multiple drop down list)

$
0
0

As I don't have any idea what you're trying to do in your SP, I will try to explain it in broader terms. One of the parameters of your SP is the segment. Instead of passing a single segment name , the intention is to pass a string of comma separated segment names in the segment parameter.

string segments = "segment A, segment B";

To split this in the SP, you can have a look at http://sqlperformance.com/2012/07/t-sql-queries/split-strings that gives a number of user defined functions to do this. I used the CTE one (mostly because I understand it a little). If you want to use the CTE one. just copy the code and paste it in a query window in SSMS and run it to create the function.

The example below how to use the function is based on an existing table (tblEmployees) that I already had. The column name of interest is 'name'.

A select query that return records for a comma separated list of specified employee names

DECLARE @names NVARCHAR(MAX) = N'roma,davinia,vivian';
select * from tblEmployees where name in(select item from dbo.SplitStrings_CTE(@names, N','))

An insert query to insert new employees (name only) from a comma separated list specified employees

DECLARE @names NVARCHAR(MAX)
set @names = N'eulender,pontsho,tumelo,piotr'
insert into tblEmployees (name) select item from dbo.SplitStrings_CTE(@names, N',')

Note: do not use spaces because the will be added to the name (segment in your case)

I hope this helps for your SP.

With regards to the dropdownlist, an earlier post stated that you can not select multiple entries. So you have to change that control to the suggested ListBox. It's too late now, but I will see if I can find time tomorrow to look at your code and modify (part of) it to use a ListBox.


Viewing all articles
Browse latest Browse all 20

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>