cancel
Showing results for 
Search instead for 
Did you mean: 

How can I capture the parameter values the user entered in ASP.NET

Former Member
0 Kudos

How can I capture the Crystal Report built-in parameter values that the user entered during runtime in ASP.NET. I need to log what the user is selecting.

Accepted Solutions (1)

Accepted Solutions (1)

Adam_Stone
Active Contributor
0 Kudos

I believe a postback happens after the user enters the parameters. You may be able to get them from the viewers parameter field collection.

Former Member
0 Kudos

Trying to capture parameters using the CrystalReportViewer object ParameterFieldInfo. Unfortunately, the collection is empty with count=0 even after user entered data. Is there a particular event when I should look? Am I looking at the correct collection?

Dim myParameters As ParameterFields

myParameters = myCrystalReportViewer.ParameterFieldInfo

Former Member
0 Kudos

There were several CrystalReportViewer events that had the parameterFieldsInfo collection valued.

BeforeRender

AfterRender

Unload

I'm going to use the Unload event. I don't think I should have any problems capturing there.

Additionally the parameters were valued in the BeforeRenderObject and AfterRenderObject, but those events fire multiple times for each object on the report.

Former Member
0 Kudos

I got the parameter values, but now I have another problem. The CrystalReportViewer_Unload event occurs after the Page_load and Page_Unload events. I'm trying to store the values and my routine needs to log the user who entered the parameters. However, I'm getting an error when I check who the user is, it's saying the Request object is not available in this context during the CrystalReportViewer_Unload event.

Former Member
0 Kudos

I solved the 'request is out of context' issue by including the HttpContext.Current reference in front of Request.

HttpContext.Current.Request

I have now accomplished my goal and the code is working well. My page allows the user to select from a list of Crystal reports. I'm using the CrystalReportViewer_Unload event to capture the collected parameters. I wrote a routine to capture based on the type of parameter, either descrete or range types, then I add those values to a string to record what the user selected. Then I use my activitylog update routine to record the user selection after adding the HttpContext to reference the Request object. This parameter capture routine is working for any report they select. If there are no parameters or no values entered it simply doesn't log until valued, once logged, I use a boolean flag/session variable to identify that those parameters were already written to the log. Because the Unload event will fire everytime they change the page of the report etc... so I have to block those additional log recordings which would be duplicates. I put a boolean/session flag clearing in the click event so when they either change reports or click display again, it will reset so the parameters valued on the next report will also be captured.

Answers (0)