This question is locked. New answers and comments are not allowed.
Hi,
Telerik version ASP:NET MVC Version 2010.03.1318.340
ASP.NET MVC3
Razor view engine
When editing (updating) mode=inline the columns I have described as readonly show up correctly as readonly, but do not give the readonly values back to the controller.
when I make a breakpoint on a line (see bold line below) the readonly properties of my terminal object are null.
For not readonly properties all modified data is given back correctly to the controller.
I am puzzled, why?
Cheers,
Jyri
My view is Strongly typed
@model IEnumerable<CargoFlowPoco.Terminal>
...
...
@(Html.Telerik().Grid(Model)
.Name("Grid")
.DataKeys(keys => keys.Add(o => o.Id))
.DataBinding(dataBinding => dataBinding
.Server()
.Select("Index", "Terminal")
.Insert("Create", "Terminal")
.Update("SaveUpdate", "Terminal")
.Delete("Delete", "Terminal"))
.Columns(columns =>
{
columns.Command(commands =>
{
commands.Edit();
commands.Delete();
}).Width(200);
columns.Bound(o => o.Code).Width(100);
columns.Bound(o => o.RegionName).Width(200);
columns.Bound(o => o.InsertByUserId).Width(200).ReadOnly();
columns.Bound(o => o.InsertTimestamp).Format("{0:g}").Width(120).ReadOnly();
})
.Sortable(sorting => sorting.Enabled(true))
.Pageable(paging => paging.Enabled(true))
.Footer(true)
)
My Terminal Controller
[HttpPost]
public ActionResult SaveUpdate(int id, Terminal terminal)
{
try
{
terminal.UpdateTimestamp = DateTime.Now;
_cRepository = new TerminalRepository(_uow);
_cRepository.Attach(terminal);
_uow.Save();
return RedirectToAction("Index");
}
catch
{
return RedirectToAction("Index");
}
}
public ActionResult Index()
{
_cRepository = new TerminalRepository(_uow);
return View(_cRepository.All());
}
My objects are POCO and for validation I am using the "buddy object" approach suggested in ScottGu's blog
So I have auto generated class and its buddy class where validations are described
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
namespace CargoFlowPoco
{
public partial class Terminal
{
#region Primitive Properties
public virtual decimal Id
{
get;
set;
}
public virtual string Code
{
get;
set;
}
public virtual string RegionName
{
get;
set;
}
public virtual string InsertByUserId
{
get;
set;
}
public virtual System.DateTime InsertTimestamp
{
get;
set;
}
public virtual string UpdateByUserId
{
get;
set;
}
public virtual Nullable<System.DateTime> UpdateTimestamp
{
get;
set;
}
}
// Buddy class
namespace CargoFlowPoco
{
[MetadataType(typeof(TerminalValidator))]
public partial class Terminal
{
}
public class TerminalValidator
{
public virtual decimal Id
{get;set;
}
[Required(ErrorMessage="Required field")]
public virtual string Code
{
get;
set;
}
[Required(ErrorMessage = "Required field")]
[RegularExpression("^[a-zA-Z]+", ErrorMessage="Use only letters a-Z")]
[StringLength(20,ErrorMessage="Max length is 20")]
public virtual string RegionName
{
get;
set;
}
[ReadOnly(true)]
public virtual string InsertByUserId
{
get;
set;
}
public virtual System.DateTime InsertTimestamp
{
get;
set;
}
public virtual string UpdateByUserId
{
get;
set;
}
public virtual Nullable<System.DateTime> UpdateTimestamp
{
get;
set;
}
}
}
Telerik version ASP:NET MVC Version 2010.03.1318.340
ASP.NET MVC3
Razor view engine
When editing (updating) mode=inline the columns I have described as readonly show up correctly as readonly, but do not give the readonly values back to the controller.
when I make a breakpoint on a line (see bold line below) the readonly properties of my terminal object are null.
For not readonly properties all modified data is given back correctly to the controller.
I am puzzled, why?
Cheers,
Jyri
My view is Strongly typed
@model IEnumerable<CargoFlowPoco.Terminal>
...
...
@(Html.Telerik().Grid(Model)
.Name("Grid")
.DataKeys(keys => keys.Add(o => o.Id))
.DataBinding(dataBinding => dataBinding
.Server()
.Select("Index", "Terminal")
.Insert("Create", "Terminal")
.Update("SaveUpdate", "Terminal")
.Delete("Delete", "Terminal"))
.Columns(columns =>
{
columns.Command(commands =>
{
commands.Edit();
commands.Delete();
}).Width(200);
columns.Bound(o => o.Code).Width(100);
columns.Bound(o => o.RegionName).Width(200);
columns.Bound(o => o.InsertByUserId).Width(200).ReadOnly();
columns.Bound(o => o.InsertTimestamp).Format("{0:g}").Width(120).ReadOnly();
})
.Sortable(sorting => sorting.Enabled(true))
.Pageable(paging => paging.Enabled(true))
.Footer(true)
)
My Terminal Controller
[HttpPost]
public ActionResult SaveUpdate(int id, Terminal terminal)
{
try
{
terminal.UpdateTimestamp = DateTime.Now;
_cRepository = new TerminalRepository(_uow);
_cRepository.Attach(terminal);
_uow.Save();
return RedirectToAction("Index");
}
catch
{
return RedirectToAction("Index");
}
}
public ActionResult Index()
{
_cRepository = new TerminalRepository(_uow);
return View(_cRepository.All());
}
My objects are POCO and for validation I am using the "buddy object" approach suggested in ScottGu's blog
So I have auto generated class and its buddy class where validations are described
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated from a template.
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
namespace CargoFlowPoco
{
public partial class Terminal
{
#region Primitive Properties
public virtual decimal Id
{
get;
set;
}
public virtual string Code
{
get;
set;
}
public virtual string RegionName
{
get;
set;
}
public virtual string InsertByUserId
{
get;
set;
}
public virtual System.DateTime InsertTimestamp
{
get;
set;
}
public virtual string UpdateByUserId
{
get;
set;
}
public virtual Nullable<System.DateTime> UpdateTimestamp
{
get;
set;
}
}
// Buddy class
namespace CargoFlowPoco
{
[MetadataType(typeof(TerminalValidator))]
public partial class Terminal
{
}
public class TerminalValidator
{
public virtual decimal Id
{get;set;
}
[Required(ErrorMessage="Required field")]
public virtual string Code
{
get;
set;
}
[Required(ErrorMessage = "Required field")]
[RegularExpression("^[a-zA-Z]+", ErrorMessage="Use only letters a-Z")]
[StringLength(20,ErrorMessage="Max length is 20")]
public virtual string RegionName
{
get;
set;
}
[ReadOnly(true)]
public virtual string InsertByUserId
{
get;
set;
}
public virtual System.DateTime InsertTimestamp
{
get;
set;
}
public virtual string UpdateByUserId
{
get;
set;
}
public virtual Nullable<System.DateTime> UpdateTimestamp
{
get;
set;
}
}
}