Tech
Forums
Jobs
Books
Events
Interviews
Live
More
Learn
Training
Career
Members
Videos
News
Blogs
Post
An Article
A Blog
A Video
An Ebook
An Interview Question
Register
Login
2
Reply
object reference not set in asp.net
Cassie Mod
8 years ago
334
Reply
Hi i got the following error,
Does somebody now how to fix it ?
model:
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity;
using System.Linq;
using System.Web;
namespace TelerikMvcApp1.Models
{
public class ProgramStatus
{
[Key]
public string ProgramName { get; set; }
public DateTime ProgramLastRun { get; set; }
}
public class ProgramStatusContext : DbContext
{
public DbSet<ProgramStatus> Stats { get; set; }
}
}
controller:
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using TelerikMvcApp1.Models;
namespace TelerikMvcApp1.Controllers
{
public class ProgramStatusController : Controller
{
private ProgramStatusContext db = new ProgramStatusContext();
// GET: ProgramStatus
public ActionResult Index()
{
var waarde = db.Stats.First().ProgramLastRun;
return View();
}
}
}
view:
@model TelerikMvcApp1.Models.ProgramStatus
@{
ViewBag.Title = "Index";
}
<div id="background">
@(Html.Kendo().Calendar().Value(Model.ProgramLastRun) // This gives an error The object is set to an instance of an object (how can i fix it ???)
.Name("Calender")
)
</div>
<style>
#background {
width: 254px;
height: 250px;
margin: 30px auto;
padding: 69px 0 0 11px;
background: url('@Url.Content("~/content/web/calendar/calendar.png")') transparent no-repeat 0 0;
}
#calendar {
width: 241px;
}
</style>
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
How to save data from RichTextBox Data in Sql server 2008 us
database