i am designing a project in .net 4.0 using mvc3. I am using two attribute name
and fname
(father name).
my controller class:
loginController.cs
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using MvcMovie.Models;
namespace MvcMovie.Controllers
{
public class loginController : Controller
{
private logindata db = new logindata();
//
// GET: /login/
public ViewResult Index()
{
return View(db.loginobj.ToList());
}
//
// GET: /login/Details/5
public ViewResult Details(int id)
{
// login login = db.loginobj.Find(id);
login login = db.loginobj.Find(2) ;
return View(login);
}
//
// GET: /login/Create
public ActionResult Create()
{
return View();
}
//
// POST: /login/Create
[HttpPost]
public ActionResult Create(login login)
{
if (ModelState.IsValid)
{
db.loginobj.Add(login);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(login);
}
//
// GET: /login/Edit/5
protected override void Dispose(bool disposing)
{
db.Dispose();
base.Dispose(disposing);
}
}
}
model class
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;
login.cs
namespace MvcMovie.Models
{
public class login
{
public int ID { get; set; }
public string name{get; set;}
public string fname { get; set; }
}
public class logindata : DbContext
{
public DbSet<login> loginobj { get; set; }
}
}
view.cshtml
@model IEnumerable<MvcMovie.Models.login>
@{
ViewBag.Title = "Index";
}
<h2>Index</h2>
<p>
@Html.ActionLink("Create New", "Create")
</p>
<table>
<tr>
<th>
name
</th>
<th>
fname
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.name)
</td>
<td>
@Html.DisplayFor(modelItem => item.fname)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
@Html.ActionLink("Details", "Details", new { id=item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
</td>
</tr>
}
</table>
I want to ask that where is data stored which is created by me? means how can I see that table of entries which is done by me?
whenever i click of .sdf file then there is a problem occured as shown in following picture, what should i do to solve this problem. should i installed something. i installed visual studio 2010 and sql server 2008.