sql and dropdown-list


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: sql and dropdown-list

  1. #1
    nouhad Guest

    sql and dropdown-list


    Is there a way before displaying data from ms-sql in a dropdown-list to start
    with a dummy item --Select All-- instead of showing the very first record
    of the database??
    An example would be appreciated..
    Thanks
    Nouhad


  2. #2
    Russell Jones Guest

    Re: sql and dropdown-list

    Sure--don't databind the dropdown list. Instead, add the 'Select All' item,
    and then loop through the data to populate the remainder of the list. Use
    the Items.Add method of the dropdown list to add each item.

    "nouhad" <nzantout@hotmail.com> wrote in message
    news:3f09b6ec$1@tnews.web.devx.com...
    >
    > Is there a way before displaying data from ms-sql in a dropdown-list to

    start
    > with a dummy item "--Select All--" instead of showing the very first

    record
    > of the database?? .
    > An example would be appreciated..
    > Thanks
    > Nouhad
    >




  3. #3
    Chaitanya Marvici Guest

    Re: sql and dropdown-list

    Actually, there is an even easier way to do that. First, go ahead and
    databind the list and then use the following code to add your option to the
    front of the list.

    Dropdownlist.Items.Insert( 0, New ListItem( "--Select All--", "0" ) )

    That will insert your listitem into the beginning of the dropdownlist.

    Chaitanya Marvici

    "Russell Jones" <arj1@nospam.northstate.net> wrote in message
    news:3f09c091@tnews.web.devx.com...
    > Sure--don't databind the dropdown list. Instead, add the 'Select All'

    item,
    > and then loop through the data to populate the remainder of the list. Use
    > the Items.Add method of the dropdown list to add each item.
    >
    > "nouhad" <nzantout@hotmail.com> wrote in message
    > news:3f09b6ec$1@tnews.web.devx.com...
    > >
    > > Is there a way before displaying data from ms-sql in a dropdown-list to

    > start
    > > with a dummy item "--Select All--" instead of showing the very first

    > record
    > > of the database?? .
    > > An example would be appreciated..
    > > Thanks
    > > Nouhad
    > >

    >
    >




  4. #4
    Gerhard Guest

    Re: sql and dropdown-list


    And there I was writing union statements
    select ID, Name, Sort = 2 from Table
    union
    select ID = '', Name = 'All', Sort = 1
    order by Sort

    Great tip...

    Gerhard

    "Chaitanya Marvici" <chaitanya@bitmap-productions.com> wrote:
    >Actually, there is an even easier way to do that. First, go ahead and
    >databind the list and then use the following code to add your option to

    the
    >front of the list.
    >
    >Dropdownlist.Items.Insert( 0, New ListItem( "--Select All--", "0" ) )
    >
    >That will insert your listitem into the beginning of the dropdownlist.
    >
    >Chaitanya Marvici
    >
    >"Russell Jones" <arj1@nospam.northstate.net> wrote in message
    >news:3f09c091@tnews.web.devx.com...
    >> Sure--don't databind the dropdown list. Instead, add the 'Select All'

    >item,
    >> and then loop through the data to populate the remainder of the list.

    Use
    >> the Items.Add method of the dropdown list to add each item.
    >>
    >> "nouhad" <nzantout@hotmail.com> wrote in message
    >> news:3f09b6ec$1@tnews.web.devx.com...
    >> >
    >> > Is there a way before displaying data from ms-sql in a dropdown-list

    to
    >> start
    >> > with a dummy item "--Select All--" instead of showing the very first

    >> record
    >> > of the database?? .
    >> > An example would be appreciated..
    >> > Thanks
    >> > Nouhad
    >> >

    >>
    >>

    >
    >



  5. #5
    Anitha Guest

    Re: sql and dropdown-list


    Awesome tip, helped me too. Thanks Chaitanya....

    "Crystal" <x@c.com> wrote:
    >
    >Thanks so much for this code- this helped me a lot as well!
    >
    >
    >"Chaitanya Marvici" <chaitanya@bitmap-productions.com> wrote:
    >>Actually, there is an even easier way to do that. First, go ahead and
    >>databind the list and then use the following code to add your option to

    >the
    >>front of the list.
    >>
    >>Dropdownlist.Items.Insert( 0, New ListItem( "--Select All--", "0" ) )
    >>
    >>That will insert your listitem into the beginning of the dropdownlist.
    >>
    >>Chaitanya Marvici
    >>
    >>"Russell Jones" <arj1@nospam.northstate.net> wrote in message
    >>news:3f09c091@tnews.web.devx.com...
    >>> Sure--don't databind the dropdown list. Instead, add the 'Select All'

    >>item,
    >>> and then loop through the data to populate the remainder of the list.

    >Use
    >>> the Items.Add method of the dropdown list to add each item.
    >>>
    >>> "nouhad" <nzantout@hotmail.com> wrote in message
    >>> news:3f09b6ec$1@tnews.web.devx.com...
    >>> >
    >>> > Is there a way before displaying data from ms-sql in a dropdown-list

    >to
    >>> start
    >>> > with a dummy item "--Select All--" instead of showing the very first
    >>> record
    >>> > of the database?? .
    >>> > An example would be appreciated..
    >>> > Thanks
    >>> > Nouhad
    >>> >
    >>>
    >>>

    >>
    >>

    >



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center