1

我有一个包含许多列的现有表,我想在其中为表内的数据创建一个搜索框。

我正在使用 ASPX 页面。谁能给我一个例子,以便我至少可以在那里参考我的项目?

谢谢。

    <table class="table table-bordered">
    <tr>
        <th>
           <%: Html.ActionLink("Employee", "Index", new { sortOrder = ViewBag.NameSortParm }) %>
        </th>
        <th>
             <%: Html.ActionLink("Department", "Index", new { sortOrder = ViewBag.DeptSortParm }) %>
        </th>
        <th>
          <%: Html.ActionLink("Local", "Index") %>

        </th>
        <th>
          <%: Html.ActionLink("Position", "Index") %>

        </th>
        <th>
             <%: Html.ActionLink("DirectLine", "Index") %>
        </th>
        <th>
          <%: Html.ActionLink("Plant", "Index") %>
        </th>

    </tr>

<% foreach (var item in Model) { %>
    <tr>
        <td>
           <h6> <%: Html.DisplayFor(modelItem => item.Emp_Name) %></h6>
        </td>
        <td>
             <h6> <%: Html.DisplayFor(modelItem => item.Emp_Dept) %> </h6>
        </td>
        <td>
           <h5> <b><%: Html.DisplayFor(modelItem => item.Emp_Local) %></b></h5>
        </td>
        <td>
             <h6> <%: Html.DisplayFor(modelItem => item.Emp_Position) %> </h6>
        </td>
        <td>
            <h6> <%: Html.DisplayFor(modelItem => item.Emp_DirectLine) %>  </h6>
        </td>
        <td>
            <h6> <%: Html.DisplayFor(modelItem => item.Emp_Entity) %> </h6>
        </td>

    </tr>
<% } %>
</table>

和我的控制器

public ActionResult Index(string nameString, string local, string dept )
    {
        ViewBag.Title = "Phone Directory";
        List<PD_Employee> model = db.PD_Employee.ToList();


    } ....... This is what I'm gonna do.

两天后我会为此赏金!

4

1 回答 1

0

如果您需要基于其中一个获取数据nameStringlocal或者dept您必须使用or条件 in linq

List<PD_Employee> model = db.PD_Employee.Where(x => (x.Name == nameString || x.Local == local || x.Dept = dept)).ToList();
于 2015-05-22T10:16:37.280 回答