Quantcast
Channel: Telerik Forums RSS
Viewing all articles
Browse latest Browse all 78072

Problem when using ViewBag in EditorTemplate

$
0
0

The View is rendered empty as if there is an exception when Editor is generated.
The DropDownList is not populated in the Editor.
If the Bind is commented in the Editor, the view is rendered and the Editor display the dropdownlist of course with no content.
So The problem comes from the Bind.
Any Help will be appreciated

My Model
  public partial class TA_SITE_SIT
    {
    public TA_SITE_SIT()
      {
      TA_BUILDING_BUI = new HashSet<TA_BUILDING_BUI>();
      }
    [Key]
     public Guid GUID_SIT { get; set; }
    public string NAME_SIT { get; set; }
    [InverseProperty("GUID_SITNavigation")]
    public virtual ICollection<TA_BUILDING_BUI> TA_BUILDING_BUI { get; set; }
    }
  public partial class TA_BUILDING_BUI
    {
    [Key]
    public Guid GUID_BUI { get; set; }
    public Guid? GUID_SIT { get; set; }
    public string NAME_BUI { get; set; }
    [ForeignKey("GUID_SIT")]
    [InverseProperty("TA_BUILDING_BUI")]
    public virtual TA_SITE_SIT GUID_SITNavigation { get; set; }
    }

My Controller
    public async Task<IActionResult> Index()
      {
      ViewData["arSites"] = new SelectList(_context.TA_SITE_SIT, "GUID_SIT", "NAME_SIT");
      return View(await _context.TA_BUILDING_BUI.ToListAsync());
      }

My View
@(Html.Kendo().Grid<TA_BUILDING_BUI>(Model)
    .Name("Buildings")
    .Columns(columns =>
    {
        columns.Bound(model => model.NAME_BUI);
        columns.Command(command =>
        {
            command.Edit();
        });
    })
    .Editable(editable =>
    {
        editable.Mode(GridEditMode.PopUp);
        editable.TemplateName("BuildingEditor");
    })
    .DataSource(dataSource => dataSource
    .Ajax()
    .Model(model => model.Id(m => m.GUID_BUI))
    .Update(update => update.Action("Update", "Building"))
    .Destroy(destroy => destroy.Action("Destroy", "Building"))
    )
)
My Editor Template
@model TelAcces3.Models.TA_BUILDING_BUI
@(Html.Kendo().DropDownList()
          .Name("DropDownList")
          .DataTextField("NAME_SIT")
          .DataValueField("GUID_SIT")
          .BindTo(ViewBag.arSites)
)



Viewing all articles
Browse latest Browse all 78072

Trending Articles