Click here to Skip to main content
15,923,789 members
Home / Discussions / C#
   

C#

 
GeneralRe: Accessing objects Pin
Heath Stewart24-May-04 11:33
protectorHeath Stewart24-May-04 11:33 
GeneralFitting Buttons to Bitmaps Pin
Guinness4Strength24-May-04 10:28
Guinness4Strength24-May-04 10:28 
GeneralRe: Fitting Buttons to Bitmaps Pin
Heath Stewart24-May-04 11:35
protectorHeath Stewart24-May-04 11:35 
GeneralRe: Fitting Buttons to Bitmaps Pin
Guinness4Strength24-May-04 15:15
Guinness4Strength24-May-04 15:15 
GeneralRe: Fitting Buttons to Bitmaps Pin
Heath Stewart25-May-04 2:36
protectorHeath Stewart25-May-04 2:36 
GeneralRe: Fitting Buttons to Bitmaps Pin
Guinness4Strength24-May-04 15:25
Guinness4Strength24-May-04 15:25 
GeneralCR 9 for C#.net Question Pin
frank2124-May-04 10:17
frank2124-May-04 10:17 
GeneralRe: CR 9 for C#.net Question Pin
Heath Stewart24-May-04 11:40
protectorHeath Stewart24-May-04 11:40 
Depending on how you display the list of reports, you can use Activator.CreateInstance to create an instance of the report. Cast that to the ReportDocument base class and call SetDataSource with your ADO.NET DataSet.

For instance, if you use a ListBox you could set the display name to whatever you want, but set the value for each item to the corresponding .rpt name. Since this gets compiled to a class with the same name using a namespace that is your project's root namespace (the project name by default) plus any folders it's in, you could do something like this:
string reportName = "MyWebApp.Reports." + listBox1.SelectedValue;
ReportDocument report = Activator.CreateInstance(reportName, "MyWebApp.dll");
report.SetDataSource(dataSet1);
Of course, you should add error handling like try-catch blocks and conditionals (like checking for null values, etc., since throwing exceptions is expensive).

 

Microsoft MVP, Visual C#
My Articles
GeneralAdding Menu Items in C# using Visual Studio Tools for Microsoft Office Pin
mevenson24-May-04 8:39
mevenson24-May-04 8:39 
Generaldataset error Pin
MrJJKoolJ24-May-04 8:23
MrJJKoolJ24-May-04 8:23 
GeneralRe: dataset error Pin
Marc Clifton24-May-04 8:37
mvaMarc Clifton24-May-04 8:37 
GeneralRe: dataset error Pin
Dave Kreskowiak24-May-04 8:39
mveDave Kreskowiak24-May-04 8:39 
GeneralRe: dataset error Pin
MrJJKoolJ24-May-04 8:57
MrJJKoolJ24-May-04 8:57 
GeneralRe: dataset error Pin
sreejith ss nair24-May-04 20:08
sreejith ss nair24-May-04 20:08 
GeneralRe: dataset error Pin
sreejith ss nair24-May-04 20:09
sreejith ss nair24-May-04 20:09 
General64bit Pin
Dimitris Iliopoulos24-May-04 7:54
Dimitris Iliopoulos24-May-04 7:54 
GeneralRe: 64bit Pin
Marc Clifton24-May-04 8:10
mvaMarc Clifton24-May-04 8:10 
GeneralRe: 64bit Pin
Dave Kreskowiak24-May-04 8:22
mveDave Kreskowiak24-May-04 8:22 
GeneralRe: 64bit Pin
leppie24-May-04 11:04
leppie24-May-04 11:04 
GeneralCalling a Web Service Pin
MrJJKoolJ24-May-04 7:44
MrJJKoolJ24-May-04 7:44 
GeneralRe: Calling a Web Service Pin
Dave Kreskowiak24-May-04 8:07
mveDave Kreskowiak24-May-04 8:07 
GeneralRe: Calling a Web Service Pin
MrJJKoolJ24-May-04 8:18
MrJJKoolJ24-May-04 8:18 
GeneralRe: Calling a Web Service Pin
Dave Kreskowiak24-May-04 8:33
mveDave Kreskowiak24-May-04 8:33 
GeneralProperties and ArrayLists Pin
morph3us24-May-04 6:13
morph3us24-May-04 6:13 
GeneralRe: Properties and ArrayLists Pin
CWIZO24-May-04 6:37
CWIZO24-May-04 6:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.