【发布时间】:2012-03-12 01:30:49
【问题描述】:
我有以下搜索表单,其中包含:文本框和两个下拉列表:-
@using (Ajax.BeginForm("Search", "Question",
new AjaxOptions
{
HttpMethod = "GET",
InsertionMode = InsertionMode.Replace,
UpdateTargetId = "re",
LoadingElementId = "progress"
}))
{ <table >
<tr>
<th>
Description:-
</th>
<th>
<input type="text" name="q" data-autocomplete-source="@Url.Action("QuickSearch", "Question")" />
</th>
</tr>
<tr>
<th>
Difficulty Level:-
</th>
<th>
@Html.DropDownList("q2")
</th>
</tr>
<tr>
<th>
Create By:-
</th>
<th>
@Html.DropDownList("q3")
</th>
</tr>
</table>
<input type="submit" value="Search Questions" />
}
所以我如何在我的两个下拉列表中定义“任何”,以便我可以在我的搜索操作方法中编写如下内容:-
public IQueryable<Question> searchquestions3(string q, int? q2 , string)
{
return from u in entities1.Questions
where (u.Description.Contains(q) && (u.DifficultyID == q2 || q2 == "Any" ) && ( u.CreatedBy == q3 || q3 == "Any"))
select u;}
【问题讨论】:
标签: linq asp.net-mvc-3 search