-
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
-
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
>
-
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
> >
>
>
-
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
>> >
>>
>>
>
>
-
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
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks