Merhaba sqlde yer alan tablomda yer alan kayıtları form sayfasına tabloya çekmeye çalışıyorum fakat System.NullReferenceException: 'Nesne başvurusu bir nesnenin örneğine ayarlanmadı.' hatası almaktayım kolon sayısını 2 ye düşürdüm normalde fazlaydı ama yine olmadı .Nedeni ne olabilir Kodu paylaşıyorum
`@Tablo Listeleme@
<div style="overflow-x: auto; overflow-y: auto; max-height: 2500px; max-width: 100%; border: 1px solid black; padding: 10px;">
<table style="width: 1500px; border-collapse: collapse;">
<thead>
<tr>
<th style="border: 1px solid black; padding: 5px; min-width: 100px; height: 1px; font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; color: red;">Stok Id</th>
<th style="border: 1px solid black; padding: 5px; min-width: 100px; height: 1px; font-family: 'Trebuchet MS', 'Lucida Sans Unicode', 'Lucida Grande', 'Lucida Sans', Arial, sans-serif; color: red;">Fiş Numarası</th>`
Cshtml de yer alan veritabanı kodu
`@using stokambarmuhasebe.Models.Entity
@model List<StokKart>
@{ Layout = null; /* Bu sayfa için Layout kullanılmaz */ }`
Controller Kodu
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using stokambarmuhasebe.Models.Entity;
namespace stokambarmuhasebe.Controllers
{
public class StokListeleController : Controller
{
// GET: StokListele
stokambarmuhasebeEntities db = new stokambarmuhasebeEntities();
public ActionResult Index()
{
var stok = db.StokKart.ToList();
return View(stok);
}
}
}