Populate asp net mvc dropdownlist from a table in an existing model
I am new in mvc. I have a search page where there are some dropdown fields. These fields are populated from database tables. I am adding controllers and views to the model, do I need to make new connections again? I am getting an error message when I try to populate the dropdown list. Attached is the screenshot of my solution explorer, GetDeleteRecordsController.cs is the controller, GetDeleteRecords is the view folder, Model1.edmx is the existing model used by the project.
Please help.
Re: Populate asp net mvc dropdownlist from a table in an existing model
I am getting the following error message
Compiler Error Message: CS1061: 'PagedList.IPagedList<InventoryDB.Models.invent>' does not contain a definition for 'Description1' and no extension method 'Description1' accepting a first argument of type 'PagedList.IPagedList<InventoryDB.Models.invent>' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 71: <td>
Line 72: <div class="form-group">
Line 73: @Html.LabelFor(model => model.Description1, htmlAttributes: new { @class = "control-label col-md-2" })
Line 74: <div class="col-md-10">
Line 75: @Html.DropDownList("Description1", null, htmlAttributes: new { @class = "form-control" })
Following is the portion of my Controller code, I am trying to populate the Description1 dropdown:
Re: Populate asp net mvc dropdownlist from a table in an existing model
Changing viewbag & control to currdescription1 did not help, then I am getting following error message.
Compiler Error Message: CS1061: 'PagedList.IPagedList<InventoryDB.Models.invent>' does not contain a definition for 'CurrDescription1' and no extension method 'CurrDescription1' accepting a first argument of type 'PagedList.IPagedList<InventoryDB.Models.invent>' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 106: <td>
Line 107: <div class="form-group">
Line 108: @Html.LabelFor(model => model.CurrDescription1, htmlAttributes: new { @class = "control-label col-md-2" })
Line 109: <div class="col-md-10">
Line 110: @Html.DropDownList("CurrDescription1", null, htmlAttributes: new { @class = "form-control" })
Source File: c:\Users\spramanik\Documents\Visual Studio 2019\Projects\InventoryDB\InventoryDB\Views\GetDeleteRecords\Index.cshtml Line: 108
Re: Populate asp net mvc dropdownlist from a table in an existing model
Changing viewbag & control to currdescription1 did not help, then I am getting following error message.
Compiler Error Message: CS1061: 'PagedList.IPagedList<InventoryDB.Models.invent>' does not contain a definition for 'CurrDescription1' and no extension method 'CurrDescription1' accepting a first argument of type 'PagedList.IPagedList<InventoryDB.Models.invent>' could be found (are you missing a using directive or an assembly reference?)
Source Error:
Line 106: <td>
Line 107: <div class="form-group">
Line 108: @Html.LabelFor(model => model.CurrDescription1, htmlAttributes: new { @class = "control-label col-md-2" })
Line 109: <div class="col-md-10">
Line 110: @Html.DropDownList("CurrDescription1", null, htmlAttributes: new { @class = "form-control" })
Source File: c:\Users\spramanik\Documents\Visual Studio 2019\Projects\InventoryDB\InventoryDB\Views\GetDeleteRecords\Index.cshtml Line: 108
Re: Populate asp net mvc dropdownlist from a table in an existing model
I do not understand the Compiler Error Message: CS1061: 'PagedList.IPagedList<InventoryDB.Models.invent>' does not contain a definition for 'CurrDescription1' and no extension method 'CurrDescription1' accepting a first argument of type 'PagedList.IPagedList<InventoryDB.Models.invent>' could be found (are you missing a using directive or an assembly reference?)
Following is my PagedListPager code and db.tblDescription1 is in model.
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index",
new
{
page,
currDescription1 = ViewBag.CurrDescription1,
Re: Populate asp net mvc dropdownlist from a table in an existing model
I do not understand the Compiler Error Message: CS1061: 'PagedList.IPagedList<InventoryDB.Models.invent>' does not contain a definition for 'CurrDescription1' and no extension method 'CurrDescription1' accepting a first argument of type 'PagedList.IPagedList<InventoryDB.Models.invent>' could be found (are you missing a using directive or an assembly reference?)
Following is my PagedListPager code and db.tblDescription1 is in model.
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount
@Html.PagedListPager(Model, page => Url.Action("Index",
new
{
page,
currDescription1 = ViewBag.CurrDescription1,