navigation
 Monday, May 07, 2007

We recently decided to use Developer Express XtraReports for one of our projects. While it's an impressive product with rich functionality, its design-time support within a web project definitely isn't as robust as it is within a windows project. After some trial and error, I discovered the trick to getting the designer preview tab to work with a parameterized query. Here's how it's done:

  1. In a web project, add a new XtraReport
  2. With the XtraReports designer open, double-click on a DataAdapter. If no DataAdapters are visible in your toolbar (none were in mine by default), you'll have to add them to the toolbar manually.
  3. Configure the DataAdapter using the wizard
  4. In the property grid, navigate to the DataAdapter's SelectCommand | Parameters property. Use the Parameters dialog to set a default value for each parameter. This will enable the report to execute the command at design-time.
  5. Select "Generate DataSet" from the DataAdapter's context menu. In the dialog that appears, make sure to check the box that says "Add this dataset to designer."
  6. The report's DataSource, DataMember, and DataAdapter properties should already be set correctly. Click on the report and examine the properties to confirm.
  7. Try adding a few fields to the detail band of the report, then click the preview tab. After a short delay, the preview should appear!

This approach uses DataAdapter classes directly. The default adapter created by Visual Studio if you create the DataSet first and then add a table will be a TableAdapter. TableAdapters will not work with this approach, because they have no facility to set default parameter values at design time. Unfortunately, the only adapters that appear in the XtraReports' DataAdapter property editor are TableAdapters. However, if you click in the grid and start typing the name of your DataAdapter, the property grid will locate it and assign it to the property correctly.

Name
E-mail
Home page

Comment (Some html is allowed: a@href@title, i, strike, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview