I'm referring to http://www.telerik.com/help/reporting/object-data-source-how-to-bind-to-data-set.html just in case my other post will have a reply that I need to use *.aspx for report in MVC for data set...
Right now, I can open the report but it is showing no data. If SELECT Name, ProductCategoryID FROM Production.ProductCategory where ProductCategoryID < 4, it will actually show 3 row of data (direct query from database), but instead, what I get is a repeat of the header 3 times. If I omit the where statement from the sql query, it will show 4 row of data, and the web page report also will show the header 4 times...
I'll appreciate help (or working project file Q3 2014, visual studio 2013)
Default.cs
========
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var objectDataSource = new Telerik.Reporting.ObjectDataSource();
objectDataSource.DataSource = GetAllData(); // GetData returns a DataSet with three tables
objectDataSource.DataMember = "ProductCategory";
//Telerik.Reporting.Report report = new Telerik.Reporting.Report();
Report2 report = new Report2(); //added this instead...
report.DataSource = objectDataSource;
Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
reportSource.ReportDocument = report;
reportViewer1.ReportSource = reportSource;
reportViewer1.RefreshReport();
}
}
static DataSet GetAllData()
{
const string connectionString =
"Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=True";
string selectCommandText = "SELECT Name, ProductCategoryID FROM Production.ProductCategory where ProductCategoryID < 4;;" +
"SELECT Name, ProductCategoryID FROM Production.ProductSubcategory;" +
"SELECT Name, ProductNumber FROM Production.Product;";
SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, connectionString);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
dataSet.Tables[0].TableName = "ProductCategory";
dataSet.Tables[1].TableName = "ProductSubcategory";
dataSet.Tables[2].TableName = "Product";
return dataSet;
}
Right now, I can open the report but it is showing no data. If SELECT Name, ProductCategoryID FROM Production.ProductCategory where ProductCategoryID < 4, it will actually show 3 row of data (direct query from database), but instead, what I get is a repeat of the header 3 times. If I omit the where statement from the sql query, it will show 4 row of data, and the web page report also will show the header 4 times...
I'll appreciate help (or working project file Q3 2014, visual studio 2013)
Default.cs
========
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
var objectDataSource = new Telerik.Reporting.ObjectDataSource();
objectDataSource.DataSource = GetAllData(); // GetData returns a DataSet with three tables
objectDataSource.DataMember = "ProductCategory";
//Telerik.Reporting.Report report = new Telerik.Reporting.Report();
Report2 report = new Report2(); //added this instead...
report.DataSource = objectDataSource;
Telerik.Reporting.InstanceReportSource reportSource = new Telerik.Reporting.InstanceReportSource();
reportSource.ReportDocument = report;
reportViewer1.ReportSource = reportSource;
reportViewer1.RefreshReport();
}
}
static DataSet GetAllData()
{
const string connectionString =
"Data Source=.;Initial Catalog=AdventureWorks;Integrated Security=True";
string selectCommandText = "SELECT Name, ProductCategoryID FROM Production.ProductCategory where ProductCategoryID < 4;;" +
"SELECT Name, ProductCategoryID FROM Production.ProductSubcategory;" +
"SELECT Name, ProductNumber FROM Production.Product;";
SqlDataAdapter adapter = new SqlDataAdapter(selectCommandText, connectionString);
DataSet dataSet = new DataSet();
adapter.Fill(dataSet);
dataSet.Tables[0].TableName = "ProductCategory";
dataSet.Tables[1].TableName = "ProductSubcategory";
dataSet.Tables[2].TableName = "Product";
return dataSet;
}