如何使用 TelerikExtension 控件创建 Asp.net Mvc3 应用程序
我已经使用 Telerik rad Controls 开发了小型 Asp.net MVC3 应用程序,因为我尝试获取数据列表,我已经创建了强类型视图控件,它创建了所有控件,我运行应用程序,它显示错误,例如对象引用空异常 在我的数据库中,我有 10 条记录,那么为什么它会出现错误,请帮助我...这里我发布了我的代码,请参考一次。
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TelerikMvcApplication1.Models.tb1_post>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Index</h2>
<fieldset>
<legend>tb1_post</legend>
<div class="display-label">post</div>
<div class="display-field"><%: Model.post %></div>
<div class="display-label">postdate</div>
<div class="display-field"><%: String.Format("{0:g}", Model.postdate) %></div>
<div class="display-label">username</div>
<div class="display-field"><%:Model.username %></div>
</fieldset>
<p>
<%: Html.ActionLink("Edit", "Edit", new { id=Model.postid }) %> |
<%: Html.ActionLink("Back to List", "Index") %>
</p>
</asp:Content>
I have develop small Asp.net MVC3 application using Telerik rad Controls with in that i have try to get the list of data for that i have create strong type view control,it is create all the controls and i run the application it showing error like Object Reference null Exception
in my database i have 10 records then why it shoeing the error please help me ...here i have post my code please refer this once.
<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<TelerikMvcApplication1.Models.tb1_post>" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
Index
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<h2>Index</h2>
<fieldset>
<legend>tb1_post</legend>
<div class="display-label">post</div>
<div class="display-field"><%: Model.post %></div>
<div class="display-label">postdate</div>
<div class="display-field"><%: String.Format("{0:g}", Model.postdate) %></div>
<div class="display-label">username</div>
<div class="display-field"><%:Model.username %></div>
</fieldset>
<p>
<%: Html.ActionLink("Edit", "Edit", new { id=Model.postid }) %> |
<%: Html.ActionLink("Back to List", "Index") %>
</p>
</asp:Content>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误发生在第一次引用模型时,因此模型为空。确保 MVC 控制器正确实例化视图的模型。
The error is happening at the first reference to the model, therefore the Model is null. Make sure that the MVC controller is properly instantiating the model for the view.