我有一個(gè)基本的 asp.net mvc web 應(yīng)用程序。它與我的數(shù)據(jù)庫(kù)相連,其中有許多記錄。我需要它在頁(yè)面頂部有一個(gè)過(guò)濾器選項(xiàng)和一個(gè)搜索名稱的搜索文本框。過(guò)濾器框應(yīng)該是一個(gè)包含所有列名稱和選擇的選項(xiàng)的下拉框,與該選項(xiàng)相關(guān)的所有記錄都顯示在主索引頁(yè)面上。我試過(guò)這樣做,但它給了我錯(cuò)誤。我附加了以下內(nèi)容:DataFormsController(索引方法)、索引 html 頁(yè)面和 .models 頁(yè)面以及我在運(yùn)行應(yīng)用程序時(shí)遇到的錯(cuò)誤。如果有人可以幫助我,我將不勝感激。謝謝?。?!RiskApplication.models 代碼:using System.Collections.Generic;//using Microsoft.AspNetCore.Mvc.Rendering;using System.Web.Mvc;namespace RiskApplication.Models{ public class RiskApplicationModel { public List<DataForm> dataForms; public SelectList owners; public string department { get; set; } }}index.cshtml: @model IEnumerable<RiskApplication.Models.DataForm>@{ ViewBag.Title = "Index";}<h2>RiskPrescreen Application 2018</h2><p> @Html.ActionLink("Create New", "Create")</p><form asp-controller="DataForms" asp-action="Index" method="get"> <p> <select asp-for="department" asp-items="Model.owners"> <option value="">All</option> </select> Application Name: <input type="text" name="SearchString"> <input type="submit" value="Search" /> </p></form><table class="table"> <tr> <th> @Html.DisplayNameFor(model => model.Name) </th> @*<th> @Html.DisplayNameFor(model => model.Application_Exec) </th> <th> @Html.DisplayNameFor(model => model.SME) </th> <th> @Html.DisplayNameFor(model => model.Project_Directory_Location) </th> <th> @Html.DisplayNameFor(model => model.IRDR_name) </th> <th> @Html.DisplayNameFor(model => model.Description) </th> <th> @Html.DisplayNameFor(model => model.Risk_Statement) </th>*@ <th> @Html.DisplayNameFor(model => model.InherentRisk) </th> @*<th> @Html.DisplayNameFor(model => model.AppOwner_DD.AppOwnerDes) </th> <th>*@ @* @Html.DisplayNameFor(model => model.C1_DD.C1) </th>
ASP.NET MVC C# Web 應(yīng)用程序 - 從數(shù)據(jù)庫(kù)過(guò)濾/搜索獲取錯(cuò)誤
慕標(biāo)琳琳
2021-11-21 17:09:59