Модуль отчета Mvc с переключателями и полем поиска в виде текстового поля
Ссылка на объект null
Код Контроллера
Ошибка возникает при вызове страницы в режиме просмотра в строке-----
////
@Html.ValidationMessageFor(x => x.search_type)///
Что я уже пробовал:
<pre> [Authorize] [HttpGet] public ActionResult ReportModule(string ac) { DbAccess da = new DbAccess(); DisplayLndRep dn = new DisplayLndRep(); LoginViewModel uinfo = new LoginViewModel(); uinfo = TempData["UserInfo"] as LoginViewModel; lnd_prgm min_details = new lnd_prgm(); dn.PageSize = 10; dn.LoginDetails = da.FindLoginDetails(User.Identity.Name); dn.FullName = da.FindUserInfoAD(User.Identity.Name).FullName; min_details = da.FindMeetingDetails(ac); if (min_details != null) { dn.FeedbackDetails = min_details; } //else //{ // min_details.prgm_id = null; // dn.FeedbackDetails = min_details; //} dn.FeedbackDetailList2 = da.FindAllMeetings(); return View(dn); }
Код бритвы
@using System.Web.Helpers @model LndFeedbackReport.ViewModels.DisplayLndRep @{ Layout = "~/Views/Shared/_Layout.cshtml"; } @*<br />*@ <div class="row"> <div class="panel panel-success" style="padding-top: 0px;"> <div class="panel-heading"> <span style="color:blue">Welcome</span> <span style="color:black">User : </span><span style="color:red">@Model.FullName</span> <span style="color:black">Salary Code : </span><span style="color:red">@Model.EmployeeId</span> <span style="color:black">Designation : </span><span style="color:red">@Model.Designation</span> <span style="color:black">Department : </span><span style="color:red"> @Model.DepartmentName </span> </div> </div> </div> <div> @if (TempData["notice"] != null) { <p class="alert alert-danger" id="successMessage">@TempData["notice"]</p> } </div> @if (@Model.FeedbackDetailList2.Count() > 0) { <div class="row"> @*@using (Ajax.BeginForm("SearchItems", "Home", new AjaxOptions { HttpMethod = "Post", UpdateTargetId = "result" }))*@ @using (Html.BeginForm("SearchRepItems", "Home", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { @class = "form-horizontal", role = "form", enctype = "multipart/form-data" })) { @Html.AntiForgeryToken() @Html.ValidationSummary(false) @Html.HiddenFor(x => x.Lnd_Program.prgm_id) <div class="form-horizontal"> <div class="form-group"> <span class="control-label col-md-3" style="font-weight:bold">Search items</span> <div class="col-md-9 col-lg-9"> <div class="col-md-4 col-lg-4"> @Html.TextBoxFor(x => x.search_text, new { maxlength = "100", @class = "form-control", autocomplete = "off" }) </div> <div class="col-md-8 col-lg-8"> @Html.RadioButtonFor(x => x.search_type, "0", new { @onchange = "ToggleInfo();" }) Individual. @Html.RadioButtonFor(x => x.search_type, "1", new { @onchange = "ToggleInfo();" }) Training Institute. @*@Html.RadioButtonFor(x => x.search_type, "2", false) Minute ID*@ @Html.ValidationMessageFor(x => x.search_type) </div> </div> </div> <div class="row col-md-12 pull-left"> <div class="form-group"> <div class="col-md-offset-5 col-md-12"> <button type="submit" id="NwSave" class="btn btn-info">Search</button> <a class="btn btn-default" href="@Url.Action("Header", "Home", new { ac = @Model.Lnd_Program.prgm_id})">Reset</a> </div> </div> </div> </div> } </div> } <hr /> @*</div>*@ <hr /> <br /> <div class="wrap"> <div class="content"> @Html.AntiForgeryToken() <div class="inner-content" style="border:none"> <span class="text-primary" style="color:crimson; font-size:larger">List of Feedback Submitted</span> </div> </div> </div> <br /> </div> </div> </div>