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>
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.
精彩评论