Convert System.Data.DataTable into Swissaddonframework.Grid.DataTable
mindpoint
Hello,
I want to import an Excel Sheet into a Grid. Excel is delivering its content through a System.Data.DataTable object. This is not compatible with the Grid's datatable. How can I convert it?
I need to import the filled Excel content dynamically into the Grid, so I do not know the structure of the Grid.
Has anyone an idea?
I have used the example of this forum to read the Excel file and it is delivering an DataTable. It would be nice if I can convert this object directly into the framework's Grid Datatable.
Andreas Achleitner
hi
i dont think there is a convert function
you have to do it yourself like this
SwissAddonFramework.UI.Components.Grid g;
System.Data.DataTable dt;
//g= grid;
//dt= excle table
g.DataTable.Clear();
foreach (System.Data.DataColumn dc in dt.Columns)
for(int i=0;i<dt.Columns.Count;i++)
{
g.DataTable.Columns.Add("" + i, SwissAddonFramework.UI.Components.DataColumn.DataColumnTypes.AlphaNumeric,254);
}
for (int i = 0; i < dt.Rows.Count; i++)
{
g.DataTable.Rows.Add();
for (int j = 0; j < dt.Columns.Count; j++)
{
g.DataTable.SetValue("" + j, i, "" + dt.Rows[i][j]);
}
}
Paolo Manfrin
Hi,
much faster would be to load the table from xml
SwissAddonFramework.UI.Components.Grid g = null;
g.DataTable.LoadFromXml(...)
hth
paolo
0
Please sign in to leave a comment.
Comments
0 comments