TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Anjali Khan
NA
867
224.5k
char' does not contain a definition for 'id' IN MVC4 ?
Apr 24 2017 3:45 AM
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: <tr>
Line 19: <td>
Line 20: @item.ID
Line 21: </td>
Line 22: <td>
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";
}
<h2>Show Database value in DataTable</h2>
<div>
<table>
<thead>
<tr>
<th>ID</th>
<th>NAME</th>
<th>ADDRESS</th>
</tr>
</thead>
@foreach (var item in ViewBag.custDetails)
{
<tr>
<td>
@item.ID
</td>
<td>
@item.NAME
</td>
<td>
@item.ADDRESS
</td>
</tr>
}
</table>
</div>
FOLLOWED THE BELOW LINK
http://www.c-sharpcorner.com/uploadfile/a2cc7b/show-database-values-in-table-using-mvc-razor/
Reply
Answers (
2
)
How to open command prompt using asp.net
why this error comes