Click here to Skip to main content
13,295,051 members (89,071 online)
Click here to Skip to main content
Add your own
alternative version


4 bookmarked
Posted 25 Feb 2010

Programmatically Pass Parameters into Crystal Reports from ASP.NET (C#) - Part 2

, 26 Feb 2010
Rate this:
Please Sign up or sign in to vote.
How to programmatically pass parameters into Crystal Reports from ASP.NET, using C# - Part 2.


This is the second part of my article: Programmatically Pass Parameters into Crystal Reports from ASP.NET (C#) - Part 1.

Using the code

We use the filters variable which is declared as a ParamType class:

public class FilterType
  public const string DateTime = "DateTime";
  public const string MultiSelect = "MultiSelect";
  public const string String = "String";
  public FilterType()

public class ParamType
  private TextBox[] datetimeFilters = new TextBox[100];
  private xMilk.DropCheck[] multiselectFilters = new xMilk.DropCheck[100];
  private TextBox[] stringFilters = new TextBox[100];
  public string[] filterType = new string[100];
  private int index = -1;
  public ParamType()
  public void AddDateTimeFilter(TextBox myTextBox)
    index += 1;
    filterType[index] = FilterType.DateTime;
    datetimeFilters[index] = myTextBox;
  public void AddMultiSelectFilter(xMilk.DropCheck myDropCheck)
    index += 1;
    filterType[index] = FilterType.MultiSelect;
    multiselectFilters[index] = myDropCheck;
  public void AddStringFilter(TextBox myTextBox)
    index += 1;
    filterType[index] = FilterType.String;
    stringFilters[index] = myTextBox;
  public string GetParamTextByIndex(int i)
    string returnText = "";
    switch (filterType[i])
      case FilterType.DateTime:
        returnText = datetimeFilters[i].Text;
      case FilterType.MultiSelect:
        returnText = multiselectFilters[i].Text;
      case FilterType.String:
        returnText = stringFilters[i].Text;
    return returnText;
  public string GetParamTypeByIndex(int i)
    return filterType[i];




In this sample, when the user clicks on report1 which uses four parameters (two DateTime, and two multiselect type), the ReportView.aspx page will be dynamically created. The datetime picker has a simple client-side JavaScript which was added as an attribute in the AddDateTimeFilter() method. The multiselect filters use a special DropCheck webcontrol which is not a standard built-in webcontrol, but can be downloaded as a DLL.


There is a known small bug in this sample and I'm hoping to get an answer here. The bug: when you click on report1, everything goes fine, but after that, if you click on report2, the ReportView.aspx page does not refresh. The second report has only three parameters, but the first report's parameters are coming in again, and this is really annoying.

I hope you found this article useful, and if you have any questions, please let me know.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mihaly Sogorka
Website Administrator
Hungary Hungary
Working with Microsoft Dynamics NAV since 2007.

You may also be interested in...

Comments and Discussions

GeneralPublishing OK, but JScript doesn't appear to run Pin
Member 173821517-May-10 17:18
memberMember 173821517-May-10 17:18 
GeneralRe: Publishing OK, but JScript doesn't appear to run Pin
Mihaly Sogorka17-May-10 22:26
memberMihaly Sogorka17-May-10 22:26 
GeneralRe: Publishing OK, but JScript doesn't appear to run [modified] Pin
Mihaly Sogorka17-May-10 22:54
memberMihaly Sogorka17-May-10 22:54 
GeneralPublishing Woes Pin
Member 173821516-May-10 19:57
memberMember 173821516-May-10 19:57 
GeneralRe: Publishing Woes Pin
Mihaly Sogorka16-May-10 22:42
memberMihaly Sogorka16-May-10 22:42 
GeneralDTP closer Pin
Member 173821516-May-10 16:55
memberMember 173821516-May-10 16:55 
GeneralRe: DTP closer Pin
Mihaly Sogorka16-May-10 22:47
memberMihaly Sogorka16-May-10 22:47 
Generalcalendarsetup Application setting Pin
Member 173821513-May-10 16:02
memberMember 173821513-May-10 16:02 
GeneralRe: calendarsetup Application setting [modified] Pin
Mihaly Sogorka13-May-10 23:02
memberMihaly Sogorka13-May-10 23:02 
GeneralMy vote of 1 Pin
Dave Kreskowiak26-Feb-10 2:24
mvpDave Kreskowiak26-Feb-10 2:24 

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.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.171207.1 | Last Updated 26 Feb 2010
Article Copyright 2010 by Mihaly Sogorka
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid