This is a migrated thread and some comments may be shown as answers.
No validation errors are being displayed on Grid
0 Answers 20 Views
This is a migrated thread and some comments may be shown as answers.
James Lam
Top achievements
Rank 2
James Lam asked on 19 Aug 2010, 11:54 PM
When I edit or insert a new row, I don't get feedback when an update/insert fails.  Any help would be appreciated.

My grid code looks like the following:
<asp:Content ContentPlaceHolderID="MainContent" runat="server">
<div style="margin: 10px 0px;">Article - Grid View</div>
<%= Html.Telerik().Grid<Article>()
        .DataKeys(keys => keys.Add(p => p.article_id))
        .ToolBar(commands => commands.Insert())
        .DataBinding(dataBinding => dataBinding.Ajax()
            .Select("_SelectAjaxEditing", "ArticleGridView")
            .Insert("_InsertAjaxEditing", "ArticleGridView")
            .Update("_SaveAjaxEditing", "ArticleGridView")
            .Delete("_DeleteAjaxEditing", "ArticleGridView"))
        .Columns(columns =>
            columns.Bound(p => p.CategoryInitials).Title("Cat");
            columns.Bound(p => p.description).Width(130);
            columns.Bound(p => p.ColorName);
            columns.Bound(p => p.Cash);
            columns.Bound(p => p.registration_number).Title("Article #");
            columns.Bound(p => p.route);
            columns.Bound(p => p.BinName);
            columns.Bound(p => p.DivisionName);
            columns.Bound(p => p.DateLost);
            columns.Command(commands =>
        .Pageable(p => { p.PageSize(20); })
<%= Html.Telerik().ScriptRegistrar() %>

My controller looks like the following:
public ActionResult _SaveAjaxEditing(int id, FormCollection collection)
   var article = Article.Load(id);
   if (!string.IsNullOrEmpty(collection["description"])) {
      article.description = collection["description"];
   } else {
      ModelState.AddModelError("description", "description cannot be empty.");
   article.ColorName = collection["ColorName"]; = collection["cash"];
   article.registration_number = collection["registration_number"];
   article.route = collection["route"];
   article.BinName = collection["BinName"];
   article.DivisionName = collection["DivisionName"];
   DateTime d;
   if (DateType.TryParse(collection["date_lost"], d)) {
      article.date_lost = collection["date_lost"];
   } else {
      ModelState.AddModelError("date_lost", "invalid date.");
   return View(new GridModel(Article.FetchAll()));

(TryUpdateModule method keeps throwing an "An item with the same key has already been added." exception, so that's why I'm not using it.)


No answers yet. Maybe you can help?

Asked by
James Lam
Top achievements
Rank 2
Share this question