HI FRNDS
I HAVE A TABLE WITH STORED PROCEDURE .HERE I AM DISPLAYING DB DATA ON TABLE
IF I AM DISPLAYINH THE DATA SO GETTING ERROR LIKE
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: 'char' does not contain a definition for 'ID'
Source Error:
Line 18:
Line 19:
Line 20: @item.ID
Line 21:
Line 22:
HOW TO SOLVE THIS PROBLEM
MY TABLE IS
CREATE TABLE [dbo].[CustomerInfo](
[ID] [int] NOT NULL,
[NAME] [varchar](50) NULL,
[ADDRESS] [varchar](100) NULL,
CONSTRAINT [PK_CustomerInfo] 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]
PROCEDURE --
CREATE PROCEDURE [dbo].PROC_CUSTOMER_SELECT_RECORED
AS
BEGIN
SELECT ID,NAME,ADDRESS FROM CustomerInfo
END
GO
1 - CREATED EDMX
2 - CONTROLLER -- namespace showdataontable.Controllers
{
public class HomeController : Controller
{
//
// GET: /Home/
public ActionResult Index()
{
CustomerEntities1 cust = new CustomerEntities1();
var data = cust.PROC_CUSTOMER_SELECT_RECORED().ToString();
ViewBag.custDetails = data;
return View();
}
}
}
3 - VIEWS --
@{
ViewBag.Title = "Show Database value in DataTable";
}
Show Database value in DataTable
| ID | NAME | ADDRESS |
|---|---|---|
@item.ID | @item.NAME | @item.ADDRESS |
FOLLOWED THE BELOW LINK
http://www.c-sharpcorner.com/uploadfile/a2cc7b/show-database-values-in-table-using-mvc-razor/
2 Replies
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Anjali KhanPosted Apr 24, 2017, 4:47 AM
Ramesh PalanivelPosted Apr 24, 2017, 4:36 AM