Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Manipulating Data Prior To Display
Message
De
07/12/2004 13:35:26
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
07/12/2004 09:35:16
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00967471
Message ID:
00967545
Vues:
8
>I am retrieving an ArrayList from a third party .NET web service, and trying to display some of the results on an ASP.NET web page. In fact, I have already managed to get this far.
>
>However, the data is not in the order in which I want it. The data I am extracting contains a text value for each row, the last characters of which are a date in the format dd-mmm-yy. What I want to do is to read out those dates, and sort the list in reverse date order (ie newest first), and then display that list on my web page.
>
>Now, in VFP I could do that in two seconds flat. However, this is c#...
>
>Help please.
>
>TIA, Kevin

Kevin,
Generally I prefer it to serialize it back into an XML and create a dataset that I can manipulate easier. If I'm sure what I'd get is simply representable by a table than create a datatable.

ie: Get web service result into a dataset
XmlSerializer xs = new XmlSerializer(typeof(myWebService.myClass));
MemoryStream ms = new MemoryStream();
TextWriter writer =  new StreamWriter(ms);
xs.Serialize(writer, wr);
ms.Seek(0,SeekOrigin.Begin);
DataSet ds = new DataSet("MyDataSet");
ds.ReadXml(ms,XmlReadMode.Auto);
Get an array of rows into a datatable:
myWS.myType[] rows = webservice.someGetMethod("parameter"); 
DataTable dt = new DataTable("myData");
System.Reflection.FieldInfo[] fi = rows[0].GetType().GetFields();
for(int i=0; i<fi.Length;i++)
{
  dt.Columns.Add(fi[i].Name,fi[i].FieldType).AllowDBNull = true ;
}
foreach(myWS.myType rw in rows)
{
   DataRow dr = dt.NewRow();
   for(int i=0; i<fi.Length;i++)
   {
	dr[i] = fi[i].GetValue(rw);
   }
   dt.Rows.Add(dr);
}
PS: There should be much easier ways but I don't know yet.
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform