Using Drop Down List with Gridview Query

Discussion in 'ASP .Net' started by Bishop, Dec 18, 2006.

  1. Bishop

    Bishop Guest

    I have a query similar to this: "Select ProductID, ProductName,
    ProductDescription where MFGID = @MFGID". I use a Drop Down List populated
    with the MFGID's to populate the @MFGID variable. My question is, using
    this technique, is there a way to say "Return all Manufactures"? If not,
    any suggestions on a good technique for this?
    Bishop, Dec 18, 2006
    #1
    1. Advertising

  2. Bishop

    David Wier Guest

    You might add a 'Select All' item to the top of the dropdownlist (item 0) -
    give it a value of -1
    Then, make your stored procedure have an if/then, so that if @MFGID is -1,
    return all, if not, use your other sql statement

    You can do this in code, also, if you're not using Stored Procedures
    (however, doing so would probably be a good idea)

    --
    David Wier
    MVP/ASPInsider
    http://aspnet101.com
    http://aspexpress.com


    "Bishop" <> wrote in message
    news:...
    > I have a query similar to this: "Select ProductID, ProductName,
    > ProductDescription where MFGID = @MFGID". I use a Drop Down List

    populated
    > with the MFGID's to populate the @MFGID variable. My question is, using
    > this technique, is there a way to say "Return all Manufactures"? If not,
    > any suggestions on a good technique for this?
    >
    >
    David Wier, Dec 18, 2006
    #2
    1. Advertising

  3. Bishop

    Bishop Guest

    The query is bound to the gridview and I'm trying to avoid changing it with
    my VB Code. Can I use If/Then in my SQL query without it being a stored
    procedure?



    "David Wier" <> wrote in message
    news:%...
    > You might add a 'Select All' item to the top of the dropdownlist (item
    > 0) -
    > give it a value of -1
    > Then, make your stored procedure have an if/then, so that if @MFGID is -1,
    > return all, if not, use your other sql statement
    >
    > You can do this in code, also, if you're not using Stored Procedures
    > (however, doing so would probably be a good idea)
    >
    > --
    > David Wier
    > MVP/ASPInsider
    > http://aspnet101.com
    > http://aspexpress.com
    >
    >
    > "Bishop" <> wrote in message
    > news:...
    >> I have a query similar to this: "Select ProductID, ProductName,
    >> ProductDescription where MFGID = @MFGID". I use a Drop Down List

    > populated
    >> with the MFGID's to populate the @MFGID variable. My question is, using
    >> this technique, is there a way to say "Return all Manufactures"? If not,
    >> any suggestions on a good technique for this?
    >>
    >>

    >
    >
    Bishop, Dec 18, 2006
    #3
  4. Bishop

    David Wier Guest

    You'd just need to add an if/then in your code, where you are implementing
    your Select statement:
    if (whatever) then
    mySQLTExt="Select.....
    else
    mySQLTExt="Select...something else"
    end if

    --
    David Wier
    MVP/ASPInsider
    http://aspnet101.com
    http://aspexpress.com


    "Bishop" <> wrote in message
    news:...
    > The query is bound to the gridview and I'm trying to avoid changing it

    with
    > my VB Code. Can I use If/Then in my SQL query without it being a stored
    > procedure?
    >
    >
    >
    > "David Wier" <> wrote in message
    > news:%...
    > > You might add a 'Select All' item to the top of the dropdownlist (item
    > > 0) -
    > > give it a value of -1
    > > Then, make your stored procedure have an if/then, so that if @MFGID

    is -1,
    > > return all, if not, use your other sql statement
    > >
    > > You can do this in code, also, if you're not using Stored Procedures
    > > (however, doing so would probably be a good idea)
    > >
    > > --
    > > David Wier
    > > MVP/ASPInsider
    > > http://aspnet101.com
    > > http://aspexpress.com
    > >
    > >
    > > "Bishop" <> wrote in message
    > > news:...
    > >> I have a query similar to this: "Select ProductID, ProductName,
    > >> ProductDescription where MFGID = @MFGID". I use a Drop Down List

    > > populated
    > >> with the MFGID's to populate the @MFGID variable. My question is,

    using
    > >> this technique, is there a way to say "Return all Manufactures"? If

    not,
    > >> any suggestions on a good technique for this?
    > >>
    > >>

    > >
    > >

    >
    >
    David Wier, Dec 18, 2006
    #4
  5. Bishop

    Bishop Guest

    OK, Thanks for the info!

    "David Wier" <> wrote in message
    news:...
    > You'd just need to add an if/then in your code, where you are implementing
    > your Select statement:
    > if (whatever) then
    > mySQLTExt="Select.....
    > else
    > mySQLTExt="Select...something else"
    > end if
    >
    > --
    > David Wier
    > MVP/ASPInsider
    > http://aspnet101.com
    > http://aspexpress.com
    >
    >
    > "Bishop" <> wrote in message
    > news:...
    >> The query is bound to the gridview and I'm trying to avoid changing it

    > with
    >> my VB Code. Can I use If/Then in my SQL query without it being a stored
    >> procedure?
    >>
    >>
    >>
    >> "David Wier" <> wrote in message
    >> news:%...
    >> > You might add a 'Select All' item to the top of the dropdownlist (item
    >> > 0) -
    >> > give it a value of -1
    >> > Then, make your stored procedure have an if/then, so that if @MFGID

    > is -1,
    >> > return all, if not, use your other sql statement
    >> >
    >> > You can do this in code, also, if you're not using Stored Procedures
    >> > (however, doing so would probably be a good idea)
    >> >
    >> > --
    >> > David Wier
    >> > MVP/ASPInsider
    >> > http://aspnet101.com
    >> > http://aspexpress.com
    >> >
    >> >
    >> > "Bishop" <> wrote in message
    >> > news:...
    >> >> I have a query similar to this: "Select ProductID, ProductName,
    >> >> ProductDescription where MFGID = @MFGID". I use a Drop Down List
    >> > populated
    >> >> with the MFGID's to populate the @MFGID variable. My question is,

    > using
    >> >> this technique, is there a way to say "Return all Manufactures"? If

    > not,
    >> >> any suggestions on a good technique for this?
    >> >>
    >> >>
    >> >
    >> >

    >>
    >>

    >
    >
    Bishop, Dec 18, 2006
    #5
    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. SirPoonga
    Replies:
    2
    Views:
    735
    Ben Strackany
    Jan 7, 2005
  2. weiwei
    Replies:
    0
    Views:
    994
    weiwei
    Jan 5, 2007
  3. msimmons
    Replies:
    0
    Views:
    449
    msimmons
    Jul 16, 2009
  4. Replies:
    5
    Views:
    245
  5. Replies:
    3
    Views:
    270
Loading...

Share This Page