473,382 Members | 1,386 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,382 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 2199
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
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.