How can I use a multiselect listbox to pass parameter to a SQL SP

Discussion in 'ASP .Net Web Controls' started by Jeff Thur, Feb 14, 2005.

  1. Jeff Thur

    Jeff Thur Guest

    I have a program where the user does database lookups. I
    need to have a listbox where thue user can select one or
    more states and a regular textbox to select a last name.
    I am not sure how I can do this. I figure that the
    programmer must build the criteria from the listbox
    itself. Any ideas on how to pass the multiple selections
    to a SQL Stored Procedure. The Textbox part is no
    problem. Thanks for any help.
    Jeff Thur, Feb 14, 2005
    #1
    1. Advertising

  2. Jeff Thur

    Riki Guest

    Jeff Thur wrote:
    > I have a program where the user does database lookups. I
    > need to have a listbox where thue user can select one or
    > more states and a regular textbox to select a last name.
    > I am not sure how I can do this. I figure that the
    > programmer must build the criteria from the listbox
    > itself. Any ideas on how to pass the multiple selections
    > to a SQL Stored Procedure. The Textbox part is no
    > problem. Thanks for any help.


    First concatenate the values into a string, separated by commas.
    Pass this string to your sproc.

    Then, in your SQL command, use the IN operator like this:
    .... WHERE myField IN (@values) ...

    --

    Riki
    Riki, Feb 14, 2005
    #2
    1. Advertising

  3. Use dataset, and DataAdapter that populates the changes in your dataset to
    the database using your stored procedure.

    Hope that helps!
    Regards,
    Kostadin Kostov

    "Jeff Thur" wrote:

    > I have a program where the user does database lookups. I
    > need to have a listbox where thue user can select one or
    > more states and a regular textbox to select a last name.
    > I am not sure how I can do this. I figure that the
    > programmer must build the criteria from the listbox
    > itself. Any ideas on how to pass the multiple selections
    > to a SQL Stored Procedure. The Textbox part is no
    > problem. Thanks for any help.
    >
    Kostadin Kostov, Feb 14, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JIK

    multiselect dropdown

    JIK, Feb 6, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    8,088
    PeterBrunone
    May 13, 2009
  2. Lenard Gunda
    Replies:
    3
    Views:
    1,239
    =?Utf-8?B?S2FubmFuLlYgW01DU0QubmV0XQ==?=
    Aug 17, 2005
  3. Martin

    Unexpected behaviour of Listbox MultiSelect

    Martin, Oct 18, 2005, in forum: ASP .Net Web Controls
    Replies:
    5
    Views:
    328
    Steven Cheng[MSFT]
    Jan 24, 2006
  4. Nick Nelson

    Listbox Multiselect as filter for Gridview

    Nick Nelson, Feb 28, 2007, in forum: ASP .Net Web Controls
    Replies:
    8
    Views:
    1,132
    chiefsss
    Aug 24, 2009
  5. Jay Pondy

    ObjectDataSource / MultiSelect ListBox

    Jay Pondy, Sep 22, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    484
    Jay Pondy
    Sep 22, 2007
Loading...

Share This Page