Solved

dropdown list bounditem position.

Posted on 2009-05-07
2
223 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

803 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