i want display result (when i enter the application no in Id textbox,it will display the customer FirstName,LastName,Address in respective textboxes
instead of displaying it in webgrid,in the same page by using EF.
i am using mvc4,visual studio 2012 and EF.Thanks in advance.Can anyone please help me.
CREATE TABLE [dbo].[tblCustomer](
[Id] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [varchar](50) NULL,
[LastName] [varchar](50) NULL,
[Address] [varchar](50) NULL,
CONSTRAINT [PK_tblCustomer] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
[Id] [int] IDENTITY(1,1) NOT NULL,
[FirstName] [varchar](50) NULL,
[LastName] [varchar](50) NULL,
[Address] [varchar](50) NULL,
CONSTRAINT [PK_tblCustomer] PRIMARY KEY CLUSTERED
(
[Id] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY]
Index View
@using (@Html.BeginForm("Index","Home",FormMethod.Post))
{
Enter Id :@Html.TextBox("Id")
<input type="submit" name="Search" value="Search" />
}
Home controller
[HttpGet]
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(int Id)
{
var qry = se.tblCustomers.Single(m => m.Id == Id);
return View("_Details", qry);
}
Details View:
Vinay SinghPosted Aug 11, 2016, 4:02 AM
Index View
@model Applicationname.Model.StudentModel@using (@Html.BeginForm("Index","Home",FormMethod.Post))
{
Enter Id :@Html.TextBox("Id")
@Html.DisplayNameFor(model => model.Address)
}
public ActionResult Index()
{
return View(objstudentmodel);
}
[HttpPost]
public ActionResult Index(int Id)
{
var qry = se.tblCustomers.Single(m => m.Id == Id);
}
Bikesh SrivastavaPosted Aug 11, 2016, 3:53 AM
Francis SusaimichaelPosted Aug 11, 2016, 3:38 AM