This is a migrated thread and some comments may be shown as answers.

[Solved] [Contribution] Row edit with EditorTemplate for complex types

0 Answers 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
sebrojas
Top achievements
Rank 1
sebrojas asked on 19 Jul 2010, 08:53 PM
If you are using complex types in your grid like in the example of Orders in employees, it's posible to get an error when you try to add a new record to the grid. I had this error and until I remove a lot of code, I found the source. Top resolve it, I have to include an If in the template:

 

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MagaSeguridadDom.Modelo.Employee>" %>
<% if (Model != null)
{ %> 
<%: Html.DropDownListFor(model => model.EmployeeID, new SelectList((IEnumerable)ViewData["employees"], "EmployeeID", "Name", Model.EmployeeID))%>
<% }
  
else
{ %> 
<%: Html.DropDownListFor(model => model.EmployeeID, new SelectList((IEnumerable)ViewData["employees"], "EmployeeID", "Name"))%> <% } %>

I hope to be useful

 

 

Tags
Grid
Asked by
sebrojas
Top achievements
Rank 1
Share this question
or