473,378 Members | 1,436 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

how to sort dropdownlist in c#


object[] SortedItems = new object[DropDownList1.Items.Count];
for (int i = 0; i < SortedItems.Length; i++)
{
SortedItems[i] = DropDownList1.Items[i];
}
Array.Sort(SortedItems);
DropDownList1.Items.Clear();
DropDownList1.Items.AddRange(SortedItems);

In the above code i copied items in dropdownlist to arraylist, i sorted arraylist , cleared dropdownlist ..i couldnt add the sorted items to dropdown..

help me

Thanks in advance..
From http://www.developmentnow.com/g/8_20...ork-aspnet.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com
Feb 6 '07 #1
2 9207
"suganya" <su************@gmail.comwrote in message
news:6a**********************************@developm entnow.com...
i couldnt add the sorted items to dropdown..
Why not...?
Feb 6 '07 #2
It's always easier to sort things before they go into a dropdown. Where is
the data for the dropdown coming from?
Peter

"suganya" <su************@gmail.comwrote in message
news:6a**********************************@developm entnow.com...
>
object[] SortedItems = new object[DropDownList1.Items.Count];
for (int i = 0; i < SortedItems.Length; i++)
{
SortedItems[i] = DropDownList1.Items[i];
}
Array.Sort(SortedItems);
DropDownList1.Items.Clear();
DropDownList1.Items.AddRange(SortedItems);

In the above code i copied items in dropdownlist to arraylist, i sorted
arraylist , cleared dropdownlist ..i couldnt add the sorted items to
dropdown..

help me

Thanks in advance..
From
http://www.developmentnow.com/g/8_20...ork-aspnet.htm

Posted via DevelopmentNow.com Groups
http://www.developmentnow.com

Feb 6 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Stanley J Mroczek | last post by:
How do you load a dropdownlist when edit is clicked in a datagrid ? <Columns> <asp:BoundColumn DataField="OptionDescription" ItemStyle-Wrap="True" HeaderText="Option...
1
by: gj | last post by:
Hi, I'm trying to sort a dropdownlist. I tried using .Sort but that doesn't work. can anyone help me? Below is the code for creating the list. foreach (DataRow quizRow in dsMain1.Tables.Rows)...
4
by: JL | last post by:
I am used a hashtable for dropdownlist data source but it seems un-sorted on output. Anybody who know the sort method in dropdownlist box? thanks a lot
5
by: Mike Kline | last post by:
Hi All! I've this strange DataView sort bug and i can't do any sorting activities! Below is my code... ---VB.NET Code--- dvFinal = New DataView(objDataSet.Tables(CON_FinalTable)) Dim...
2
by: Ali | last post by:
I am binding a hashTable to a dropDownList to pick a State (key: like New York) and sends the state designation (value: NY) to a filtering procedure. I have entered the states in the hashTable in...
3
by: Samuel Shulman | last post by:
I am looking for a simple method to sort the DropDownList after it was loaded Thank you, Samuel
0
by: suganya | last post by:
object SortedItems = new object; for (int i = 0; i < SortedItems.Length; i++) { SortedItems = DropDownList1.Items; } Array.Sort(SortedItems); DropDownList1.Items.Clear();...
2
by: gnewsgroup | last post by:
I have a GridView, in which the header of one column changes depending on the selected value of a DropDownList outside of this GridView. I did this dynamic header through protected void...
0
by: Allan | last post by:
Hi, I am having trouble when I dynamically assign sqldatasources to a gridview. If I do not sort the gridviews, everything runs well even when I change the gridview's sqldatasource by changing the...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.