This question is locked. New answers and comments are not allowed.
I want to have my own Editor Template for editing string data, but the data is always null, when I use Ajax binding, and all is right, when I'm using server side binding.
Model
Controller Action
View (Grid with Ajax binding)
Editor Template
In attach there is small example, that demonstrates this bug (Visual Studio 2008, MVC2)
Model
[KnownType(
typeof
(Post))]
public
class
Post
{
public
Post()
{
}
[ScaffoldColumn(
false
)]
public
int
Id {
get
;
set
; }
public
string
Title {
get
;
set
; }
//[DisplayFormat(ApplyFormatInEditMode = true)]
[UIHint(
"PostContent"
)]
public
string
PostContent {
get
;
set
; }
public
string
Tags {
get
;
set
; }
[HiddenInput]
[ReadOnly(
true
)]
public
DateTime CreatedDate {
get
;
set
; }
[ScaffoldColumn(
false
)]
[HiddenInput]
[ReadOnly(
true
)]
public
DateTime LastUpdatedDate {
get
;
set
; }
}
Controller Action
[GridAction]
public
ActionResult Index()
{
var posts = PostRepository.GetAll();
if
(Request.IsAjaxRequest())
return
View(
new
GridModel(posts));
return
View(posts);
}
View (Grid with Ajax binding)
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"MainContent"
runat
=
"server"
>
<% Html.Telerik().Grid(Model)
.Name("Grid")
.DataKeys(dataKeys => dataKeys.Add(m => m.Id))
.DataBinding(dataBinding =>
{
dataBinding.Ajax().Select("Index", "Home");
dataBinding.Ajax().Insert("Create", "Home");
dataBinding.Ajax().Update("Edit", "Home");
dataBinding.Ajax().Delete("Delete", "Home");
})
.Columns(columns =>
{
columns.Command(commands =>
{
commands.Edit();
commands.Delete();
}).Width(80);
columns.Bound(m => m.Title).Title("Title");
columns.Bound(m => m.PostContent).Title("Content");
columns.Bound(m => m.Tags).Title("Tags");
columns.Bound(m => m.CreatedDate).Title("Created At");
})
.Pageable(pager => pager.PageSize(10))
.Sortable()
.Editable(editing => editing.Mode(GridEditMode.InForm))
.Filterable()
.Render();
%>
</
asp:Content
>
Editor Template
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<
System.String
>" %>
<
p
>test</
p
>
<
p
>
<%=
Model // The model is always null, when I use Ajax binding,
// and all is right with server binding
%></
p
>
<
p
>test</
p
>
In attach there is small example, that demonstrates this bug (Visual Studio 2008, MVC2)