all groups > asp.net datagrid control > june 2003 >
You're in the

asp.net datagrid control

group:

Fill datagrid without database


Fill datagrid without database Yoramo
6/29/2003 11:12:20 AM
asp.net datagrid control: Hello

I need to fill in my datagrid from calcutalted date. how do I fill in my
datagrid?

yoramo

Re: Fill datagrid without database Tim
6/29/2003 4:33:58 PM
could you be a little more specific?

[quoted text, click to view]

Re: Fill datagrid without database Steve Letford
6/30/2003 10:20:17 AM
You can create a datatable fill in your details and bind it to your
datatable.

Steve

[quoted text, click to view]

Re: Fill datagrid without database yoramo
6/30/2003 10:42:45 PM
Thanks I'v done it here is an example of it.

// create a DataTable
DataTable aTbl = new DataTable("Test") ;
DataColumn aClmn ;
aClmn = new DataColumn("aaa") ;
aClmn.DataType= System.Type.GetType("System.Char");
aTbl.Columns.Add(aClmn) ;
aClmn = new DataColumn("Count") ;
aClmn.DataType= System.Type.GetType("System.Int16");
aTbl.Columns.Add(aClmn) ;
aClmn = new DataColumn("Frequency") ;
aClmn.DataType= System.Type.GetType("System.Double");
aTbl.Columns.Add(aClmn) ;
aClmn = new DataColumn("RealChar") ;
aClmn.DataType= System.Type.GetType("System.Char");
aTbl.Columns.Add(aClmn) ;
// fill in the relevant data
for (char ch = 'A' ; ch <= 'Z' ; ch++)
{
int Row = ch - 'A' ;
DataRow aRow;
aRow = aTbl.NewRow() ;
aRow["aaa"] = ch ;
aRow["Count"] = _Table[ch] ;
double aFreq = (100.0 * _Table[ch]) / _Table.TotalCount ;
aRow["Frequency"] = aFreq ;
aTbl.Rows.Add(aRow) ;
}
dataGrid2.DataSource = aTbl ;


thanks
Yoramo


[quoted text, click to view]

AddThis Social Bookmark Button