473,396 Members | 1,726 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,396 software developers and data experts.

How to load and sort Values from Hashtable into a DataColumn of a DataTable

I have a datasource that is being passed in as a Hashtable. I want to
load in all the Values (strings inside the Value, not the Keys) into a
collumn inside a DataTable. The values need to be sorted
alphabetically. What is the best way to do this? Any help is
appreciated!

Oct 27 '05 #1
4 2204
bpdace <bp********@gmail.com> wrote:
I have a datasource that is being passed in as a Hashtable. I want to
load in all the Values (strings inside the Value, not the Keys) into a
collumn inside a DataTable. The values need to be sorted
alphabetically. What is the best way to do this? Any help is
appreciated!


ArrayList list = new ArrayList(hashtable.Values);
list.Sort();

That gives you a list of the values in alphabetical order - then you
just need to load them up in whatever way you want.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 27 '05 #2
works like a charm! thanks. I got tricked into using a sortedList
instead. Wasn't working for me. This is.

Oct 27 '05 #3
works like a charm! thanks. I got tricked into using a sortedList
instead. Wasn't working for me. This is.

Oct 27 '05 #4
bpdace <bp********@gmail.com> wrote:
works like a charm! thanks. I got tricked into using a sortedList
instead. Wasn't working for me. This is.


Yes - the problem with SortedList is that it isn't a list. It's a map
which enumerates in an order sorted by key. Very, very badly named
class.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 27 '05 #5

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...
6
by: Shabam | last post by:
A web application of mine developed using C# + MS SQL runs fine normally. However when I stress test it with a load testing software (using about 60 simultaneous users) some instances start...
1
by: Robert Schuldenfrei | last post by:
Dear NG, I have successfully bound a combo box to a table when only one column was involved. I am trying to present the user with the primary key to an item-location table. The primary key...
9
by: John Kirksey | last post by:
I have a page that uses an in-place editable DataGrid that supports sorting and paging. EnableViewState is turned ON. At the top of the page are several search fields that allow the user to filter...
1
by: Biva | last post by:
Hello, I have a drop down list control in a datagrid. I can't seem to populate the control. Here is what my code looks like: <EditItemTemplate> <asp:DropDownList ID= "ddlUser5" DataSource =...
2
by: Fredrik Rodin | last post by:
All, I've been looking around for a solution to my problem for a couple of days now. In short, here's my situation: 1. I'm getting a result from a component back as a datatable and I have...
1
by: Gunjan Garg | last post by:
Hello All, I am working to create a generic datagrid which accepts a datasource(ListData - This is our own datatype) and depending on the calling program customizes itself for sorting,...
4
by: bpdace | last post by:
I have a datasource that is being passed in as a Hashtable. I want to load in all the Values (strings inside the Value, not the Keys) into a collumn inside a DataTable. The values need to be sorted...
3
by: gilly3 | last post by:
I have a column in a DataView that contains NaN. When I attempt to Sort on this column, I get: MESSAGE: Index was outside the bounds of the array. SOURCE: System.Data STACKTRACE: at...
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
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
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.