473,403 Members | 2,071 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,403 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 9209
"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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.