How to get Filtered Data in Crystal Report?


I have a list of passengers and I have some filters in the view also to search passenger according to the filter.

img1

I also have a crystal report created for the table(img1).

img2

Now what I want is, when I filter the data and search for it, I want to print and get the crystal report of only the filtered data. How can I do that?

img3

In img3, only the data of the agent named Aminul Islam is being shown here. Crystal report shows the data of the whole table, not the filtered table. Now what should I do?


Asked by:- SalmanZahir
0
: 5012 At:- 11/8/2017 5:29:10 AM
ASP.NET MVC Crystal Report

@salman can you add image of query which you are using to filter data? In your mvc controller, with the help of your query we can check issue, if you are not filtering at all you can do it using Ado.Net like DataList.where(a=>a.Name.ToLower()=“SearchQuery”).ToList() 0
By : jaiprakash - at :- 11/8/2017 5:57:52 AM
Place your c# code which you are using to filter data, also the code which you are using to get filtered values in the table 0
By : jaiprakash - at :- 11/8/2017 5:59:23 AM
No I want it dynamic. Like when I will filter the data in my view....when I will click the print button, it will only print the filtered data. 0
By : SalmanZahir - at :- 11/8/2017 6:56:58 AM






2 Answers
profileImage Answered by:- pika

Your filter query doesn't look correct, you are getting all data using || condition. Suppose In your above Filter method your agent="Salman", then C# code should be

public ActionResult Index(string agent, Datetime? searchDate,string labTest, string xrayTest, string result){
//here i am assuming all data is null except agent='Salman'
// then Model code to select only data of 'salman' would be

var model= db.tbl_final_result.Include(a=>a.tbl_registration)
.Where(a=>a.tble_registration.tbl_agent.agent_name=='Salman').ToList();

return View(model);

//do not add other conditions in Where like  (agent==null || agent= "")
// it would fetch all names where name is null, or ""
//apply similarly for .Where(a=>a.Date==searchDate)
// do not add || searchDate==null || searchDate.ToString() ==""

}

Filter like above in Crystal report and you are done, thanks, upvote and mark it as answer it helped.

1
At:- 11/8/2017 8:29:35 AM Updated at:- 11/8/2017 8:30:00 AM


profileImage Answered by:- SalmanZahir

 

This is the filter queryThis is my filter query

0
At:- 11/8/2017 6:58:45 AM






Login/Register to answer
Or
Register directly by posting answer/details

Full Name *

Email *




By posting your answer you agree on privacy policy & terms of use