This is a migrated thread and some comments may be shown as answers.

GridDataItemCollection with reportviewer

1 Answer 124 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Islam Abdel Aziz
Top achievements
Rank 1
Islam Abdel Aziz asked on 23 Feb 2010, 02:43 PM

Hello

Please I have a GridDataItemCollection and I wanto to pass it to reportviewer ,how can i do so ?

I do the following but it give me an error in reportviewer
GridDataItemCollection g = RadGrid1.MasterTableView.Items ;

 

 

 

r.DataSource =

g;

the error is it dosent the column name of my table

Thanks in advance

1 Answer, 1 is accepted

Sort by
0
Islam Abdel Aziz
Top achievements
Rank 1
answered on 24 Feb 2010, 07:49 AM
Finally I found a solution :

GridDataItemCollection

 

g = RadGrid1.MasterTableView.Items ;

 

 

 

// Create a table to store customer values.

 

 

DataTable CustomerTable = new DataTable("EventLog");

 

 

// Define the columns for the Customer table.

 

CustomerTable.Columns.Add(

new DataColumn("Action", typeof(string)));

 

CustomerTable.Columns.Add(

new DataColumn("Object", typeof(string)));

 

CustomerTable.Columns.Add(

new DataColumn("Doer", typeof(string)));

 

CustomerTable.Columns.Add(

new DataColumn("Date", typeof(DateTime)));

 

CustomerTable.Columns.Add(

new DataColumn("oldValue", typeof(string)));

 

CustomerTable.Columns.Add(

new DataColumn("newValue", typeof(string)));

 

CustomerTable.Columns.Add(

new DataColumn("EnvironmentName", typeof(string)));

 

 

DataRow dataRow;

 

 

foreach (GridDataItem item in g)

 

{

dataRow = CustomerTable.NewRow();

dataRow[0] = item[

"Action"].Text;

 

dataRow[1] = item[

"Object"].Text;

 

dataRow[2] = item[

"Doer"].Text;

 

dataRow[3] =

DateTime.Parse(item["Date"].Text);

 

dataRow[4] = item[

"oldValue"].Text;

 

dataRow[5] = item[

"newValue"].Text;

 

dataRow[6] = item[

"EnvironmentName"].Text;

 

 

CustomerTable.Rows.Add(dataRow);

}

 

 

DataSet ds = new DataSet();

 

ds.Tables.Add(CustomerTable);

r.DataSource = ds;

ReportViewer1.RefreshReport();

Tags
Grid
Asked by
Islam Abdel Aziz
Top achievements
Rank 1
Answers by
Islam Abdel Aziz
Top achievements
Rank 1
Share this question
or