English 中文(简体)
mvc 中数据与下调列表中数据的动态约束
原标题:dynamic binding of data to the dropdown list in mvc

I have a view in which I am entering two different dates, So i want that all the entries in the database between these two dates should be displayed in a drop down list. How can I do this?????

问题回答

从您控制器返回这两个日期之间的条目列表返回

enteries.Where(a => a.startdate < FirstDate &&  a => a.enddate < SecondDate  ).ToList()

然后将这些条目传递到 DroowDListFor like

@Html.DropDownListFor(model => model.entryID,
    new SelectList(model.entries, "ID", "Title"))




相关问题
Using jquery to get a partial view and updating the UI

I need to render a partial view (returned from the controller) to show some customer summary details. This will need to happen when the user clicks on a button. In the the mean time the user can ...

MVC 2 / MVC 3 / MVC 4

MVC 2 我们可以轻松地创造领域。 现在,我的问题涉及nes地区(地区内)。

Asp.Net MVC 2 - Changing the PropertyValueRequired string

Using a resx file in the App_GlobalResources directory, I ve been able to change the default message for the PropertyValueInvalid string of the model validators. But it doesn t work to translate the ...

ASP.NET MVC 3 - What features do you want to see? [closed]

I know a bunch of people that are really enjoying the improvements that ASP.NET MVC 2 made over the first release. I have just started to migrate our MVC 1 project over and so far areas has totally ...

热门标签