Question Reportviewer and RDLC files

poldie

New member
Joined
Jul 27, 2009
Messages
1
Programming Experience
10+
I've got a few questions about the ReportViewer control, when bound to what I believe is called a "Windows Report", although there seem to be a few flavours of this. I'm using a RDLC file, if that helps. I need to create reports, and populate, display and print them at run time. This is for a asp.net web app using VS 2005 and SQL Server 2000 database (soon to be upgraded to SQL Server 2005).

I don't need to create the report at run time, (maybe in the future). There don't seem to be as many resources on the net for this type of report as there are for other, simpler aspects of .net development.

Perhaps someone can answer some/all of these questions, and perhaps a pro can tell me that I'm doing this the wrong way and that there's a better approach - if so, I'm open to any or all suggestions.

1) My reports have a header/footer which are correctly being displayed at the top/bottom of each page. This is fine. I have a table in the body of the report. This table has a header which appears on each page. This is great. But I'm using grouping, so for example I might have artists, albums and songs. The artist and album each occupy a new row. Can I make them occupy the same row?

2) Sometimes at the bottom of the page after all the songs on one album it will produce the header for the next artist or album, but there's no room for any details so on the next page it'll start again with artist and/or album. Is there a way of suppressing the headers is there's no room for any details?

3) I've not been too successful adding graphics such as lines at the end of a group - can I do this? I don't seem to have many options in terms of which controls I can use in a report.

4) I've been creating datasets which consist of a tableadaptor, linked to a SP. This is great, as I can then just drag fields out of the dataset onto the table on my reportviewer control. But sometimes I need to have other data from a database on the report, such as the user requesting the report, the department he's in etc. Am I supposed to create a number of datasets with one or just a handle of fields in each dataset, or perhaps one large miscellanous dataset with one record containing 10 unconnected fields and use that?

A specific example: sometimes the columns in the report represent dates, so although the SP returns columns called `col01`, `col02` etc, they then need to be altered to read `25/12/2008`, '26/12/2008' etc, and the data will be a tick or a cross (ie integer values turned into images in the report - this works fine). What's the best way to get those dates (which change from call to call of the SP) onto the report? Currently I have a second dataset. But this means I now have 3 datasets on one report - the main one with the table detail; the descriptions of the date fields; and miscaellanous stuff like reportee, department etc. I suppose I could roll the 2nd and 3rd datasets together, but this means I then have to support SPs in the database with completely unconnected stuff in - not very clean.

5) Continuing from question 4, I seem to be limited in where I can drag fields from datasets into the report. It doesn't like fields going into the report's header/footer - it's as if it's designed for displaying multiple records, not just one. I have got around that sometimes by using =first(xxxxx) but I think that was in the table, not in the header/footer. Is there a trick to putting data from any field in a dataset into any part of a report?

6) I've had trouble with SPs which use temporary tables. I've google and found people saying you can't return temp tables, but my problem is worse than that - I can't even use temp tables in the SP which returns data, regardless of whether or not the table I'm returning from is temporary. I'm actually returning from a table variable, which works fine, but I have to do a workaround for the temp table problem - I have to recompile my SP with all the code commented out except for the line which declares the table variable, and the line which returns the data, then create the dataset/table adaptor against the SP, and then recompile the SP with the code uncommented. It's just that dataset creation step which has the problem. Is there a way around this? It seems like a bug which would be fixed very quickly but it seems to have been around for a while.

7) This may be a bad idea, but when I first encountered the `how do I change the column headings` problem from question 4, I thought perhaps the solution would be to set up an event handler for an event in the reportviewer or the form containing the reportviewer or something, and then reach into the controls and edit the data there, before it's displayed. I got nowhere with this - perhaps because I'm not very good at investigating which controls are available in a form at run time. Is this approach worth persueing, or is there always a better way?

8) Sometimes, while designing a report, I change datasets, or rework the report, and it gets into a bit of a pickle, and complains at runtime (not usually compile time) about fields which I'm not using now, but have done in the recent path. It seems that the only solution (short of starting again) is to close the file containing the report, and then use a text editor to manually remove old stuff from the file. (You have to be careful - one wrong move and you get a big red cross through the report when you open it again.) Is there some sort of refresh/clean-up option somewhere I'm missing which goes through the stuff you can see visually in the report, but removes stuff which is no longer present?

9) Since I started working on reports, I've noticed that I sometimes get a compilation error saying something like "object can not be referenced". It doesn't matter what it is, as it's not a real error message - I just compile again and it's fine, but it was annoying because I took it seriously once or twice and spent a while trying to find the problem. No file/line number is shown, and if you double click on the error message it hangs VS. I guess it's working behind the scenes to compile some aspect of the report and doesn't communicate this to VS properly. Perhaps. It's annoying - is there some setting I can change to avoid seeing this?


Uh..that's it for now! Thanks in advance for any help/advice you can offer.
 
Back
Top