0
實際上,我是新來這種技術,我使用mvc2架構。我無法將數據從我的模型加載到查看頁面。我使用強類型模型EventListing.Models.EventInfo。我需要模型格式的輸出。我如何使用我的選擇功能強烈鍵入模型/需要在模型格式輸出
型號
public class EventInfo
{
public int OPR { get; set; }
public int EVENT_ID { get; set; }
public string SUBSITE { get; set; }
public static DataTable Select()
{
DataTable myDataTable = new DataTable();
Dbhelper DbHelper = new Dbhelper();
DbCommand cmd = DbHelper.GetSqlStringCommond("SELECT * FROM WS_EVENTINFO");
myDataTable.Load(DbHelper.ExecuteReader(cmd));
return myDataTable;
}
控制器
public ActionResult List()
{
return View(EventModel.EventList());
}
查看
<%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<EventListing.Models.EventInfo>" %>
<% foreach (var model in EventListing.Models.EventModel.EventList())
{ %>
<tr>
<td>
<%= Html.ActionLink(model.TITLE, "Detail", new { id = model.EVENT_ID })%>
您的控制器實際上並未調用您提供的模型。我建議你需要以一種方式選擇你的數據,以獲得一個'EventInfo'對象的'List'來啓動,並顯示'EventModel.EventList()'代碼。這個問題是無法回答的。 –