Я хочу получить идентификатор класса, на мой взгляд, показатель.
i need dropdown list of my class tablein my index view when i use viewbag method but it still show error in my index view ClassID,how i can remove this issue plz some one help me..
Что я уже пробовал:
THIS IS MY iNDEX VIEW. @using PagedList; @using PagedList.Mvc; @model PagedList.IPagedList<opr.Data.C_QuestionTable> @model opr.Data.myclass @{ ViewBag.Title = "Index"; } <h2>Index</h2> <div class="alert-success form-control m-auto w-75 custom-form"> <div class="col-6 pb-3 input-control"> <label for="ex3"> Select Class:</label> @Html.DropDownListFor(model => model., (SelectList)ViewBag.dataForDropDowns, new { @class = "form-control select2ddl" }) </div> <p> @Html.ActionLink("Create New", "Create") </p> </div> this my controller using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using opr.Data; using PagedList; using PagedList.Mvc; namespace opr.Controllers { public class OnlineQuizeController : Controller { examsEntities db = new examsEntities(); public ActionResult Index(int?page) { var mod1 = db.myclasses.Select(s => new { s.ID, s.C_name }).ToList(); SelectList sList = new SelectList(mod1, "ID", "C_name"); ViewBag.dataForDropDown = sList; List<object> myobject = new List<object>(); myobject.Add(db.myclasses.ToList()); ViewBag.classIDs = myobject; var pageNumber = page ?? 1; var pageSize = 3; var question = db.C_QuestionTable.OrderBy(x => x.QuestionText).ToPagedList(pageNumber, pageSize); return View(question); } } }