This question is locked. New answers and comments are not allowed.
Hi,
I have a simple grid that is bound to a List when I post back the grid my list of custom types are not being implicitly created like I would expect so that I can save the list. Am I missing something or do I need to do this manually? Thanks. Justin
View:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<Flagship.Business.BusinessObjects.Language>>" %>
<style type="text/css">
.t-grid tr
{
cursor: pointer;
}
</style>
<% using (Html.BeginForm("SaveLanguages", "Admin"))
{
Html.Telerik().Grid(Model)
.Name("Languages")
.Scrollable()
.Sortable()
.Columns(columns =>
{
columns.Add(o =>
{%>
<%=Html.Hidden("LanguageID", o.LanguageID.Value)%>
<%=Html.CheckBox("IsFlagshipLanguage", o.IsFlagshipLanguage.Value, new { title = o.Name })%>
<%
}).Title("Flagship Language").Width(20);
columns.Add(o => o.Name).Width(100);
columns.Add(o =>
{
%>
<%= Html.ActionLink("Delete", "Delete","", new { @class = "t-link action-delete" })%>
<%
}).Title("Delete").Width(150);
})
.Render();
%>
<input type="submit" value="Save All" class="Button" title="Save all languages in the list" />
<% } //end form tag %>
Method on Controller:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SaveLanguages(List<Language> languages)
{
programService.SaveLanguages(languages);
return RedirectToAction("ShowLangauges", "Admin");
}
I have a simple grid that is bound to a List when I post back the grid my list of custom types are not being implicitly created like I would expect so that I can save the list. Am I missing something or do I need to do this manually? Thanks. Justin
View:
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<List<Flagship.Business.BusinessObjects.Language>>" %>
<style type="text/css">
.t-grid tr
{
cursor: pointer;
}
</style>
<% using (Html.BeginForm("SaveLanguages", "Admin"))
{
Html.Telerik().Grid(Model)
.Name("Languages")
.Scrollable()
.Sortable()
.Columns(columns =>
{
columns.Add(o =>
{%>
<%=Html.Hidden("LanguageID", o.LanguageID.Value)%>
<%=Html.CheckBox("IsFlagshipLanguage", o.IsFlagshipLanguage.Value, new { title = o.Name })%>
<%
}).Title("Flagship Language").Width(20);
columns.Add(o => o.Name).Width(100);
columns.Add(o =>
{
%>
<%= Html.ActionLink("Delete", "Delete","", new { @class = "t-link action-delete" })%>
<%
}).Title("Delete").Width(150);
})
.Render();
%>
<input type="submit" value="Save All" class="Button" title="Save all languages in the list" />
<% } //end form tag %>
Method on Controller:
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult SaveLanguages(List<Language> languages)
{
programService.SaveLanguages(languages);
return RedirectToAction("ShowLangauges", "Admin");
}