I have a list of passengers and I have some filters in the view also to search passenger according to the filter.
I also have a crystal report created for the table(img1).
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?
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?
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.
This is the filter query
Subscribe to our weekly Newsletter & Keep getting latest article/questions in your inbox weekly