1

我正在使用 asp.net mvc3(c#) 中的 WebGrid。我已经完美地完成了所有编码,但我不知道为什么 WebGrid 没有在页面上呈现。我不知道我做错了什么。我已经调试了代码和数据在里面

var grid = new WebGrid(source: Model, defaultSort: "CRM_ID");%>

但是,它没有显示。

这是我的 ASPX 页面代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<IEnumerable<CRMEvent.Models.CRM.DatabaseEntities.CRM_Dashboard_Requests>>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    Dashboard
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Dashboard</h2>
    <%    
        var grid = new WebGrid(source: Model, defaultSort: "CRM_ID");%>
<div id="grid">

    <%
        grid.GetHtml(columns: grid.Columns(
          grid.Column(columnName: "CRM_ID",header: "CRM ID", canSort: true),
         grid.Column(columnName: "MDLNO", header: "MDLNO", canSort: true),
         grid.Column(columnName: "EMP_Name", header: "Employee", canSort: true),
         grid.Column(columnName: "SERVICE_TYPE", header: "Service Type", canSort: true),
         grid.Column(columnName: "Requested_Amount", header: "Requested Amount", canSort: true),
         grid.Column(columnName: "Created_Date", header: "Date", canSort: true)
         ));
   %>
    </div>
</asp:Content>
4

1 回答 1

1

试试这样。<%=

<%= grid.GetHtml(columns: grid.Columns(
          grid.Column(columnName: "CRM_ID",header: "CRM ID", canSort: true),
         grid.Column(columnName: "MDLNO", header: "MDLNO", canSort: true),
         grid.Column(columnName: "EMP_Name", header: "Employee", canSort: true),
         grid.Column(columnName: "SERVICE_TYPE", header: "Service Type", canSort: true),
         grid.Column(columnName: "Requested_Amount", header: "Requested Amount", canSort: true),
         grid.Column(columnName: "Created_Date", header: "Date", canSort: true)
         )); %>

甚至<%: %>是 html 编码的这种语法。

于 2013-02-01T10:23:07.307 回答