Quantcast
Channel: DevNet Questions
Viewing all articles
Browse latest Browse all 8901

Populate a dropdown list in my MVC view from Kentico custom tables

$
0
0
Using Kentico 12 MVC, I created a custom table to store infos used to populate a dropdown list in my view.It is named MyCustom.Tables and have added a "ProgramName" and "ProgramID" fields with the relevant infosHow can I pass them to my view? I tried in my controller: IEnumerable@ProgramList@ allPrograms = CustomTableItemProvider.GetItems@ProgramList@("MyCustom.Tables"); and then in my view: @Html.DropDownListFor(m =@ m.Data.ProgramSelected, new SelectList(Model.Data.AllPrograms, "ProgramID", "ProgramName"), "- Please Select -", new { @class = "browser-default" }) with the following modelpublic class ProgramList { public string ProgramID { get; set; } public string ProgramName { get; set; } } But I get an error in the controller (No overload for method GetItems take 1 arguments)...I also tried to change the controller to IEnumerable allPrograms = CustomTableItemProvider.GetItems("MyCustom.Tables"); But my custom fields from my custom table are not available in this case only the default ItemID Kentico field. Any ideas?S.

Viewing all articles
Browse latest Browse all 8901

Trending Articles