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
swsh hussain
NA
11
11.6k
getting error There is no ViewData item of type 'IEnumerab
Nov 17 2015 2:24 AM
After clicking on create button without selecting any data i got an error
There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'CostCenterId'."}
this my contrller action method
public ActionResult Create()
{
ViewBag.Currency = new SelectList(db.Currencys, "Id", "Currency");
ViewBag.CostCenterId = new SelectList(db.CostCenterIds, "Cost_Center_Id", "Cost_Center_Name");
return View();
}
<tr>
<td>
@Html.LabelFor(model => model.CostCenterId)
</td>
<td>
@Html.DropDownListFor(model => model.CostCenterId, (SelectList)ViewBag.CostCenterId, "Select ", new { style = "width:200px" })
@Html.ValidationMessageFor(model => model.CostCenterId)
</td>
</tr>
<tr>
<td>
@Html.LabelFor(model => model.Currency)
</td>
<td>
@Html.DropDownListFor(model => model.Currency, (SelectList)ViewBag.Currency, "Select ", new { style = "width:200px" })
@Html.ValidationMessageFor(model => model.Currency)
</td>
</tr>
Reply
Answers (
4
)
XML element not displaying for empty values
Add dropdown list in Kendo Grid column with populated data?