Why ReportViewer Does Not Show All Records?
For me .NET ReportViewer control (Windows Forms control or ASP.NET server control) has been a useless control because I often need something more than what it gives to me! In fact I think it's provided for quick and simple reports.
But one of things that I saw and seems to be very common for some amateur developers is a problem with this control. Sometimes developers say that our report doesn't show more than one record (usually the last record or summation of all records). Today one of my colleagues at new organization had this problem and searched for it on Google and I saw that there are many other guys who have gotten in this trouble!
This problem has two common reasons. The first one is a problem with data source that doesn't generate all records and in this case the logic should be corrected in this place.
But the second one is a simple technical point. There is a distinction between a TextBox and a Table but developers put a TextBox on their reports and expect to get all their records. One of common reasons is Microsoft developers simply drag and drop a field from data sources to their report and this generates a TextBox automatically. The purpose of TextBox is to show a single value but the purpose of a Table is to show many records in a structured view so you can't use a TextBox to show all records and it only shows the last one.
Here I give an example of both results (with TextBox and with Table).
First I create a Windows Forms application and add a DataSet to keep my data. These data are as same as what I had generated for my TABLESAMPLE Clause post. I want to show both id and Value fields for first top 30 records in database. Then I create a Report to generate my reports and simply drag and drop my fields to report body.
Now I create a Windows Form and put a ReportViewer on it. Then set its report to my recently created report. The output doesn't have anything more than one record which shows the summation of all records.
But now I go back and change my report to use a Table to generate data.
Result is what I expected and it shows all records in report.
+ Wasting my time in new organization for service has an interesting result. Now I can see what's going on for lower level developers and what are their problems and questions! At least it gives me good ideas for blogging!!
[advertisement] Axosoft OnTime 2008 is four developer tools in one: bug tracking, project wiki, feature management, and help desk. It manages your development process so developers can focus on coding. Installed or Hosted – Free Single-user license -- Free 30-day team trial.
3 Comments : 05.02.07
Feedbacks
Thank You !

#1
DotNetKicks.com
05.02.2007 @ 7:48 PM