【问题标题】:Custom message inside the webgrid if empty Using Asp.net Mvc3?如果为空,则 webgrid 内的自定义消息使用 Asp.net Mvc3?
【发布时间】:2012-08-29 21:40:47
【问题描述】:

我想在下面的 else 语句中的 Web 网格内显示一条消息“未找到记录”。有人可以帮我解决这个问题吗?

<%      
var grid = new WebGrid(source: Model, defaultSort: "ProjectName", rowsPerPage: 5);
using (Html.BeginForm())
{ %> 
    <div class="resourcereprtsmain">
    <%:Html.Label("Project Name") %>
    <%: Html.DropDownList("Projects", (SelectList)ViewBag.Projects, "--Select Project--")%>   
    <br />
    <%:Html.Label("Release Phase") %>
    <%:Html.DropDownList("ReleasePhase", "--Select ReleasePhase--")%>                                      

    <input type="submit" value="search" />                            
    </div>                                                                  
    <div id="grid">
    <%:grid.GetHtml(
     tableStyle: "listing-border_c", headerStyle: "gridhead", footerStyle: "paging", rowStyle: "td-dark", alternatingRowStyle: "td-light",                            
     columns:grid.Columns(
     grid.Column("ProjectName", "Project Name"),
     grid.Column("ReleasePhase", "ReleasePhase"),
     grid.Column("Newbugs", "New Bugs"),
     grid.Column("Assignedbugs", "Assigned Bugs"),
     grid.Column("Fixedbugs", "Fixed Bugs"),
     grid.Column("Reopenedbugs", "Reopened Bugs"),
     grid.Column("Closedbugs", "Closed Bugs"),
     grid.Column("Defferedbugs", "Deffered Bugs"),
     grid.Column("NotaBug", "Not a Bug")                           
      ))%>
    </div>                  
<%} %>

【问题讨论】:

  • "...grid 下面的 else 语句" 还有什么语句?我没看到。
  • @Mohayemin..如果没有数据中的 GridView 则消息显示没有找到记录

标签: asp.net-mvc-3 webgrid


【解决方案1】:

在控制器代码中

      if (ds.Tables[0].Rows.Count == 0)
            {

                TempData["notice"] = "No Records are Not Found";

            }
            else
            {

            }

在查看代码

<% if (TempData["notice"] != null) { %>
<p><label id="msgtext" >No Records Are Not found !!!!</label></p>
 <% } %>

我得到了答案

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-04-24
    • 2011-10-17
    • 2012-02-18
    • 1970-01-01
    • 2011-11-09
    • 2017-09-28
    • 1970-01-01
    相关资源
    最近更新 更多