Aspdotnet-Suresh

aspdotnet-suresh offers C#.net articles and tutorials,csharp dot net,asp.net articles and tutorials,VB.NET Articles,Gridview articles,code examples of asp.net 2.0 /3.5,AJAX,SQL Server Articles,examples of .net technologies

Crystal Report not refreshing based on parameter values in asp.net

Jan 21, 2012
Introduction:

In this article I will explain how to refresh crystal reports based on parameter values to populate required data in asp.net


Description:

In Previous posts I explained
crystal reports example in asp.net and pass parameters to crystal reports using asp.net. After create crystal reports with search option first time I entered text and click on search button at that time reports populate with required data after that again I entered text and click search button during that time report is showing only previous data that is not updating based on search text. 

I tried many ways to solve this problem but I didn’t find way to solve this problem. After long research I find solution to refresh crystal report and displaying data based on required search text.

Previously in button click I written code like this 


protected void btnSearch_Click(object sender, EventArgs e)
{
ReportDocument reportdocument = new ReportDocument();
reportdocument.Load(Server.MapPath("CrystalReport.rpt"));
reportdocument.SetDatabaseLogon("", "", "SureshDasari", "MySampleDB");
reportdocument.SetParameterValue("Username", txtUserName.Text);
CrystalReportViewer1.ReportSource = reportdocument;
}
After research I added some extra code in button click like this

protected void btnSearch_Click(object sender, EventArgs e)
{
ReportDocument reportdocument = new ReportDocument();
reportdocument.Load(Server.MapPath("CrystalReport.rpt"));
reportdocument.SetDatabaseLogon("", "", "SureshDasari", "MySampleDB");
reportdocument.SetParameterValue("Username", txtUserName.Text);
CrystalReportViewer1.ParameterFieldInfo.Clear();
CrystalReportViewer1.ReportSource = reportdocument;
}
If you observe above two code blocks only difference is one single line i.e.


CrystalReportViewer1.ParameterFieldInfo.Clear();
By adding this line in button click it will clear the previous parameter values and allow us to search for records based on new parameter values. I hope it helps someone.

If you enjoyed this post, please support the blog below. It's FREE!

Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email.

subscribe by rss Subscribe by RSS subscribe by email Subscribe by Email

14 comments :

Karthik said...

i want to create keyboard layout in c#.net window application

Anonymous said...

thanku so muchhh

qnhata3 said...

Hi,
I have a question about crystal report in visual studio 2008. I use object crystal report viewer for show my report:

crystalReportViewer.ReportSource = reportDocument;
crystalReportViewer.ParameterFieldInfo = report.ParameterFields;

crystalReportViewer.Refresh();

When I change parameter of report on user interface , memory of program is increase about 3-5 MB. How can I clean old data before change parameter ? I don't know where is data of report. Thanks so much!

Anonymous said...

thanks

Anonymous said...

the maximum report processing jobs limit configured by your system administrator has been reached ? Please give solution of this problem

Anonymous said...

thanks... helped a lot!

Unknown said...

Hi ,suresh dasari
Thanks for ur code ,it helps me alot,keep update new suggestion to help others.
Thank u very much.

fizmhd said...

nice work .. thanks for the help ..

Unknown said...

thanks...helped a lot to me

Anonymous said...

a very nice solution. It has solved my bug that has been bugging me for 4 days. great effort.

Unknown said...

Thanks. Good work frd..

shobha said...

Thank you so much, i had wasted my couple of days on this issue. This article helped me. God Job!!

Ashu Jayara said...
This comment has been removed by the author.
Anonymous said...

CrystalReportViewer1.ParameterFieldInfo.Clear();
saved the day
thanks.

Give your Valuable Comments

Note: Only a member of this blog may post a comment.

© 2015 Aspdotnet-Suresh.com. All Rights Reserved.
The content is copyrighted to Suresh Dasari and may not be reproduced on other websites without permission from the owner.