• 1398/12/25

خطا درهنگام ثبت رکورد :

باسلام واحترام

سایت درست بالا می آمد بعد بخاطر تغییری که درگزارشم میخواستم بدهم چند فیلد به viewmodel اضافه کردم ولی تغییردیگری درقسمت ثبت برنامه ندادم الان این خطارومیده میشه راهنمایی بفرمائید.

There is no ViewData item of type 'IEnumerable<SelectListItem>' that has the key 'CenterGroups'.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: There is no ViewData item of type 'IEnumerable<SelectListItem>'

@model ViewModels.RequestRegisterViewModel

@{
    ViewBag.Title = "RequestRegistert";
}

@if (User.Identity.IsAuthenticated)
{

    if (ViewBag.State == null)
    {
        <div class="panel  panel-default " style="background-color:#F7F7F7;">

            @*<div class="panel-heading  text-center">

                    <i class="fa fa-calendar-o"></i>
                    <small>@ViewBag.DatePersion.ToString("yyyy/MM/dd")</small>

                </div>*@
            <div class="panel-body form-horizontal">
                <header><h3> ثبت درخواست / @User.Identity.Name/ @ViewBag.PlaceName <label for="lblName" style="vertical-align: middle;"></label> </h3></header>
                <hr />
                <article>
                    @if (ViewBag.RoleName != "relate")
                    {
                        if (ViewBag.IsSuccess != null)
                        {
                            <div class="alert alert-success">
                                درخواست شما با موفقیت ثبت شد .
                            </div>
                        }
                        else
                        {

                            using (Html.BeginForm())
                            {

                                @Html.AntiForgeryToken()

                                <div class="form-horizontal form-inline">
                                    @Html.ValidationSummary(true, "", new { @class = "text-danger" })
                                    <div class="row">
                                        <div class="col-sm-12">
                                            <div class="form-group">
                                                @Html.LabelFor(model => model.FromDate, htmlAttributes: new { @class = "control-label col-md-2" })
                                                <div class="col-sm-8">
                                                    @Html.EditorFor(model => model.FromDate, new { htmlAttributes = new { @class = "form-control" } })
                                                    @Html.ValidationMessageFor(model => model.FromDate, "", new { @class = "text-danger" })
                                                </div>
                                            </div>

                                            <div class="form-group">
                                                @Html.LabelFor(model => model.ToDate, htmlAttributes: new { @class = "control-label col-md-2" })
                                                <div class="col-sm-8">
                                                    @Html.EditorFor(model => model.ToDate, new { htmlAttributes = new { @class = "form-control" } })
                                                    @Html.ValidationMessageFor(model => model.ToDate, "", new { @class = "text-danger" })
                                                </div>
                                            </div>
                                        </div>
                                    </div>

                                    <hr />
                                    <div class="row">
                                        <div class="col-sm-6">
                                            <div class="form-group">
                                                <div class="col-sm-6">
                                                    <label for="form_name"> استان رفاهي</label>
                                                </div>
                                                <div class="col-sm-6">
                                                    @Html.DropDownList("CenterGroups", null, htmlAttributes: new { @class = "form-control" })
                                                    <div class="help-block with-errors"></div>
                                                </div>
                                            </div>
                                        </div>
                                        <div class="col-sm-6">
                                            <div class="form-group">
                                                @Html.LabelFor(model => model.CenterID, htmlAttributes: new { @class = "control-label col-sm-4" })
                                                <div class="col-md-6">
                                                    @Html.DropDownList("CenterID", null, htmlAttributes: new { @class = "form-control" })
                                                    @Html.ValidationMessageFor(model => model.CenterID, "", new { @class = "text-danger" })
                                                </div>
                                            </div>

                                        </div>
                                    </div>
                                    <hr />

that has the key 'CenterGroups

logo-enamadlogo-samandehi