emmee
asked on
How do I pass all selected listbox item values into paramaterised query in ASP.NET c# (web application)?
Please can anyone tell me how to pass all selected listbox items into paramaterised SQL server query.
For example if I have a listbox containing the following items [apples, pears, bananas, grapes, oranges] and apple, pears and bananas have been selected by the user onclick. How do I pass apple, pear and bananas as a parameter into sql server paramaterised query using c# so that sql can be dynamially created and retrieve data into datagrid based on users selected values
And then how would I build up as I have several multiple listboxes.
I've tried googling for examples but no luck...I know how to get values from on selected value say if its from dropdown list but dont uderstand how to do for multi select listboxes.
Thanks
For example if I have a listbox containing the following items [apples, pears, bananas, grapes, oranges] and apple, pears and bananas have been selected by the user onclick. How do I pass apple, pear and bananas as a parameter into sql server paramaterised query using c# so that sql can be dynamially created and retrieve data into datagrid based on users selected values
And then how would I build up as I have several multiple listboxes.
I've tried googling for examples but no luck...I know how to get values from on selected value say if its from dropdown list but dont uderstand how to do for multi select listboxes.
Thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Once you can get the selected items, You can build the Command object by passing Command parameters.
You can write an method which takes variable number of parameters as items and create sql parameters for each of the items passed and attach them to command object