Solved

dropdown list bounditem position.

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

The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
exporting html table data 4 28
Where is this file? 3 25
How to use NFS (Network File System) in Asp.net mvc 5? 4 45
Code works but breaks when I add one section 4 20
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display

829 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