开发者

asp.net mvc 3 - filter, sort data from more then 1 table

开发者 https://www.devze.com 2023-03-27 02:14 出处:网络
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

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?

asp.net mvc 3 - filter, sort data from more then 1 table

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();
    }
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号