Solved

dropdown list bounditem position.

Posted on 2009-05-07
2
226 Views
Last Modified: 2013-12-17
I have a dropdown list which is populated by a dataset and also one bounditem called 'Other'.

At the moment the bound item appears at the top of the dropdown list. Is it possible to put this item at the bottom of the dropdown list.

Thanks

I am using c# and asp,net
0
Comment
Question by:Mr_Shaw
2 Comments
 
LVL 3

Accepted Solution

by:
PierreBeukes earned 500 total points
ID: 24323867
Hi,

There is a whole couple of ways you could do this.

- You can add the "OTHER" manually after the databind()
- You can alter the dataset and add the other to that.

See my example below how I add 4 rows and then add a 5th in the middle.
        DropDownList1.Items.Clear();
 
        ListItem lst = new ListItem();
        lst.Value = "1";
        lst.Text = "ONE";
 
        DropDownList1.Items.Add(lst);
 
        lst = new ListItem();
        lst.Value = "2";
        lst.Text = "TWO";
 
        DropDownList1.Items.Add(lst);
 
        lst = new ListItem();
        lst.Value = "3";
        lst.Text = "THREE";
 
        DropDownList1.Items.Add(lst);
 
        lst = new ListItem();
        lst.Value = "4";
        lst.Text = "FOUR";
 
        DropDownList1.Items.Add(lst);
 
        lst = new ListItem();
        lst.Value = "5";
        lst.Text = "FIVE";
 
        DropDownList1.Items.Insert(2, lst);

Open in new window

0
 

Author Closing Comment

by:Mr_Shaw
ID: 31578908
Spot on.. thanks
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question