Read this article in your language IT | EN | DE | ES
Source: Lightweight DataTable for your Silverlight Apps
| Since there is no DataTable in Silverlight I’ve created small class that can be used to generate columns and rows in runtime in similar to the real DataTable way: DataTable table = new DataTable(); table.Columns.Add(new DataColumn() { ColumnName = "ID", DataType = typeof(int) }); table.Columns.Add(new DataColumn() { ColumnName = "Name", DataType = typeof(string) }); table.Columns.Add(new DataColumn() { ColumnName = "UnitPrice", DataType = typeof(decimal) }); table.Columns.Add(new DataColumn() { ColumnName = "Date", DataType = typeof(DateTime) }); table.Columns.Add(new DataColumn() { ColumnName = "Discontinued", DataType = typeof(bool) }); for(var i = 0; i < 1000; i++) { DataRow row = new DataRow(); row["ID"] = i; row["Name"] = names[rnd.Next(9)]; row["UnitPrice"] = prizes[rnd.Next(9)]; row["Date"] = DateTime.Now.AddDays(i); row["Discontinued"] = bools[rnd.Next(9)]; table.Rows.Add(row); } |
Class File is named Data.cs, c3 Version:
Unfortunately, there’s no VB.Net version of this, haven't gotten to it yet.
b8eb08f0-d7c8-48ce-916e-6f963e42d97e|0|.0
Code Snippets, SilverLight
silverlight, code snippets, datatable