Fill datagrid without database

Y

Yoramo

Hello

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

yoramo
 
S

Steve Letford

You can create a datatable fill in your details and bind it to your
datatable.

Steve
 
Y

yoramo

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top