I have a KendoUI web Interface with 4 columns 1-Environment-name, 2-Environment-code 3- Server-details 4-Project-details All of them are using editor template dropdown to show the values other than the Environment-name which is only a text field. When i click on Edit and select the values from all three drop-downs, it perfectly sends the value to the controller and updates the database. But in case when i click the Add New Item Button the Server-details Drop down and Project details drop-down doesn't sent the values to the controller.

This is the cs-html File.

 @(Html.Kendo().Grid<EnvironmentPOCO>()
          .Name("Grid")
          .Columns(columns =>
          {
              columns.Bound(d => d.EnvironmentName).Width(200).Title("Environment Name");
              columns.ForeignKey(d => d.EnvironmentTypeID, (List<EnvironmentTypePOCO>)ViewData["EnvironmentType"], "EnvironmentTypeID", "EnvironmentTypeCode").Width(150).Title("Environment Code").EditorTemplateName("_EnvironmentCodeDropDown");
              columns.ForeignKey(d => d.Server_ID, (List<ServerPOCO>)ViewData["Servers"], "Server_ID", "ServerName").Width(300).Title("Server Details").EditorTemplateName("_ServerDropDown");
              columns.ForeignKey(d => d.Project_ID, (List<SynergyProjectPOCO>)ViewData["SynergyProjects"], "Project_ID", "ProjectName").Width(400).Title("Project Details").EditorTemplateName("_ProjectNameDropDown");         
             // columns.ForeignKey(d => d.ServerID, (List<ServerPOCO>)ViewData["ServerDetails"], "ServerID", "ServerIP").Width(200).Title("Server IP")/*.EditorTemplateName("_ServerIPDropDown")*/;
             // columns.ForeignKey(d => d.ProjectID, (List<SynergyProjectPOCO>)ViewData["SynergyProjects"], "ProjectID", "ProjectDescription").Width(200).Title("ProjectDescription")/*.EditorTemplateName("_ProjectDescription")*/;
              columns.Command(d =>
              {
                  d.Edit();
                  d.Destroy();

              }).Width(200).Title("Action");
          }

          )

          .ToolBar(tools => tools.Create())
          .Sortable()
          .Pageable()
          .AutoBind(true)
          .Filterable()
          //.Scrollable()
          .DataSource(dataSource => dataSource
            .Ajax()
                .Model(model =>
                    {
                        model.Field(m => m.EnvironmentTypeID);

                        model.Field(m => m.Server_ID);                  

                        model.Field(m => m.Project_ID);
                        model.Field(m => m.EnvironmentName);
                        model.Id(m => m.EnvironmentID);

                    })
                .Read(read => read.Url(ViewBag.ApiBaseUrl).Type(HttpVerbs.Get))
                .Create(create => create.Url(ViewBag.ApiBaseUrl).Type(HttpVerbs.Post))
                .Update(update => update.Url(ViewBag.ApiBaseUrl).Type(HttpVerbs.Put))
                .Destroy(destroy => destroy.Url(ViewBag.ApiBaseUrl).Type(HttpVerbs.Delete))
          )

    )

_EnvironmentCodeDropDown Editor template

@(Html.Kendo().DropDownListFor(m => m)
                  .Name("EnvironmentTypeID")
                  .OptionLabel("Select Envrionment Type")
                  .DataTextField("EnvironmentTypeCode")
                  .DataValueField("EnvironmentTypeID")
                  .BindTo((List<EnvironmentTypePOCO>)ViewData["EnvironmentType"])
            )

_ProjectNameDropDown Editor Template @using List.Model.Model

@(Html.Kendo().DropDownListFor(m => m)
                  .Name("Project_ID")
                  .OptionLabel("Select Project Name")
                  .DataTextField("ProjectName")
                  .DataValueField("Project_ID")
                  .BindTo((List<SynergyProjectPOCO>)ViewData["SynergyProjects"])
            )

_ServerDropDown EditorTemplate @using List.Model.Model

@(Html.Kendo().DropDownListFor(m => m)
                  .Name("Server_ID")
                   .OptionLabel("Select Server")

                  .DataTextField("ServerName")
                  .DataValueField("Server_ID")
                  .BindTo((List<ServerPOCO>)ViewData["Servers"])
            )

Related posts

Recent Viewed