Groups | Blog | Home
all groups > dotnet performance > september 2004 >

dotnet performance : put datas from dataSet in SoretedList with C#



pepe perez via .NET 247
9/16/2004 6:57:46 AM
(Type your message here)

--------------------------------
From: pepe perez

Hi, i need pass datas from structure DataSet to SortedList but i don?t know the method.
Anybody can help me?

Thanks (very much)

-----------------------
Posted by a user from .NET 247 (http://www.dotnet247.com/)

Bob Grommes
9/16/2004 8:33:23 AM
This is more of an ADO.Net question than a performance question, so you
might have better luck on microsoft.public.dotnet.framework.adonet.

The short answer is that there is no magic method to do this, but you can
easily write your own. Just iterate through the data rows and add whatever
you want as a key / value pairs you wish to the SortedList. You might use
the primary or a candidate key field as the key, and the value might be the
entire DataRow, a selected field from the DataRow, or a wrapper object of
selected fields. It all depends on what you want to accomplish.

foreach (DataRow dr in myDataTable) {
mySortedList.Add((int)dr["keyfield"],dr);
}

--Bob

[quoted text, click to view]

AddThis Social Bookmark Button