上午 所有人,
我正在开发一个新的伙伴关系。 MVC网净应用。 其部分功能是检索LQ服务器数据库中的零部件清单。 作为解决办法的一部分,我建立了ADO.net实体数据模型,并将其命名为List。 我使用主页,希望能对其进行搜索控制。 因此,我在共同名录中编造部分:
<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of DielToolMVC.PartList)" %>
<%=Html.ValidationSummary("Please correct the errors and try again")%>
<% Using (Html.BeginForm())%>
<fieldset>
<p>
<label for="Parts">Please enter a part description or NSN.</label>
<%=Html.DropDownList("PARTNAME",Model.PARTNAME )%>
<%=Html.DropDownList("NSN", Model.NSN)%>
<%=Html.ValidationMessage("Part Name or NSN", "*")%>
</p>
<p>
<input type="submit" value="Search" />
</p>
</fieldset>
<% End Using%>
我也创建了一个部分主计长,其宗旨为: (1) 将所有部分清单放在各部分页和2号上,以查找各部分清单,并将结果归还各部分。 兹在《备件法》中:
Public Class PartsController
Inherits System.Web.Mvc.Controller
Private _entities As New Diel_inventoryEntities()
GET: /Parts/
Function Index() As ActionResult
Return View(_entities.PartList.ToList())
End Function
GET: /Parts/Details/5
Function Details(ByVal id As Integer) As ActionResult
Return View()
End Function
GET: /Parts/Create
Function Create() As ActionResult
Return View()
End Function
POST: /Parts/Create
<AcceptVerbs(HttpVerbs.Post)> _
Function Create(ByVal collection As FormCollection) As ActionResult
Try
TODO: Add insert logic here
Return RedirectToAction("Index")
Catch
Return View()
End Try
End Function
GET: /Parts/Edit/5
Function Edit(ByVal id As Integer) As ActionResult
Return View()
End Function
POST: /Parts/Edit/5
<AcceptVerbs(HttpVerbs.Post)> _
Function Edit(ByVal id As Integer, ByVal collection As FormCollection) As ActionResult
Try
TODO: Add update logic here
Return RedirectToAction("Index")
Catch
Return View()
End Try
End Function
Function Search(ByVal id As String, ByVal SearchType As String) As ActionResult
If SearchType = "description" Then
Dim SearchResult = From p In _entities.PartList _
Where p.PARTNAME = id _
Select p
Return View(SearchResult)
End If
If SearchType = "NSN" Then
Dim SearchResult = From p In _entities.PartList _
Where p.NSN = id _
Select p
Return View(SearchResult)
End If
Return View("UnknownType")
End Function
End Class
预定的搜索控制功能: 接收对Name部分或NSN的任何部分进行输入搜索,并根据这些部分进行除名选择。 我希望将搜索结果定在单独的一页。 谁能向我提供某种帮助和指导,说明如何解决这一问题和创造预期功能?
感谢
Sid
查明: 我不理解为什么我收到错误的信息。 除了ADO.net 实体数据模型(dmx文档)外,我是否需要设立一个类别来界定我模型中的每一领域? 我看到了一些在辅导中做的工作,但认为x子档案对此有所关注? 为什么这一错误信息被推翻?
相关法律:
<%@ Control Language="VB" Inherits="System.Web.Mvc.ViewUserControl(Of DielToolMVC.PartList)" %>
<%=Html.ValidationSummary("Please correct the errors and try again")%>
<% Using (Html.BeginForm("Search", "PartsController"))%>
<fieldset>
<p>
<label for="Parts">Please enter a part description or NSN.</label>
<%=Html.TextBox("searchtext") %>
<%=Html.DropDownList("PARTNAME",Model.PARTNAME )%>
<%=Html.DropDownList("NSN", Model.NSN)%>
<%=Html.ValidationMessage("Part Name or NSN", "*")%>
</p>
<p>
<input type="submit" value="Search" />
</p>
</fieldset>
<% End Using%>
部分 主计长:
Function Search(ByVal id As String, ByVal SearchType As String) As ActionResult
If SearchType = "PARTNAME" Then
Dim SearchResult = From p In _entities.PartList _
Where p.PARTNAME = id _
Select p
Return View(SearchResult)
End If
If SearchType = "NSN" Then
Dim SearchResult = From p In _entities.PartList _
Where p.NSN = id _
Select p
Return View(SearchResult)
End If
Return View("UnknownType")
End Function
Function Result(ByVal id As String, ByVal SearchResult As String) As ActionResult
Return View("SearchResult")
End Function
在对上面显示的零部件和零件进行修改后,错误信息依然存在。