asp.net mvc 3 - filter, sort data from more then 1 table
I have 4 parameters to filter (two dropdownlists and two datetime type fields) data from my database. I take data from 3 tables of this da开发者_运维问答tabase. The view should be like the view on the screen. How can I do it? Simple gridview don't present data like i want.
How can I send 4 parameters to controller?
I am using Oracle Database
As an option you can make select with LINQ:
var list = (from t1 in DataContext.Tables1
//here add you joins
select new
{
Code = t1.Code,
CompanyName = t1.Company, //for example
//...
}).ToList();
GridView.DataSource = list;
GridView.DataBind();
But this will work only if you use "hybrid" application - both classic ASP and MVC approach. Otherwise you need pass list to your view.
About parameters... For example you have layout
<select name="filter1">
//...
<select>
<select name="filter2">
//...
<select>
<input type="hidden" name="dateStart" />
<input type="hidden" name="dateEnd" />
Then in you action you will have:
public ActionResult MyAction(int filter1, string filter2, DateTime? dateStart, DateTime? dateEnd)
{
//code here
return View();
}
精彩评论