Quantcast
Channel: Telerik Blogs
Viewing all articles
Browse latest Browse all 5210

Lightweight DataTable for your Silverlight applications

$
0
0

 

UPDATE: Please visit this post for more info about dynamic objects binding!

 

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"]...

Viewing all articles
Browse latest Browse all 5210

Trending Articles