Introduction:
In this article I will explain how to refresh crystal reports based on parameter values to populate required data in asp.net
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.
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. |
|||
|
|||
14 comments :
i want to create keyboard layout in c#.net window application
thanku so muchhh
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!
thanks
the maximum report processing jobs limit configured by your system administrator has been reached ? Please give solution of this problem
thanks... helped a lot!
Hi ,suresh dasari
Thanks for ur code ,it helps me alot,keep update new suggestion to help others.
Thank u very much.
nice work .. thanks for the help ..
thanks...helped a lot to me
a very nice solution. It has solved my bug that has been bugging me for 4 days. great effort.
Thanks. Good work frd..
Thank you so much, i had wasted my couple of days on this issue. This article helped me. God Job!!
CrystalReportViewer1.ParameterFieldInfo.Clear();
saved the day
thanks.
Note: Only a member of this blog may post a comment.