Click here to Skip to main content
15,900,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi all
am doing batch editing and am using ajax binding.grid contains two rows holiday name and holiday date if holiday is same i have to throw an error message in alert.its working but i changed that holiday date and again I saved means it throwing same error the following code I have done.
C#
var Save_Options = new AjaxOptions
   {
       HttpMethod = "POST",
       Url = Url.Action( "_ManageHolidays", new { area = "Masters", controller = "MasterData"} )
              OnSuccess = "OnHolidaySuccess"
   };

Javascript function
C#
function OnHolidaySuccess( e ) {
      var container =  $(".msg_container");
       if(e.HasError==false)
           {
                $("#displayerror").hide();
                var grid = $("#grdHolidays").data("tGrid");
                grid.rebind();
                alert("Saved");
           }

        else
           {
               alert(e.Message.Message);

           }
   }

controller
C#
       [AcceptVerbs(HttpVerbs.Post)]       
        public ActionResult _ManageHolidays(ObservableCollection<HolidayModel> _holiday)
        {
 try
            {
            if (_holiday.Select(h => h.Date).Distinct().Count() == _holiday.Count)
                {
                    save code is done here                          
                 }

              else
                {
                throw new FaultException("Date cannot be same");
                }
       }
  catch (FaultException ex)
            {
             ModelState.AddModelError("", AppHelper.GetMessageFromException(ex));                         
            }
}


its working but if i changed that same date and saved means its showing same alert error because._holiday parameter count is 2 for the first time I press save but it count is 4 when I pressed save for the second time after changing the date.
Any one please Help me to come out of this Problem .
Posted
Updated 23-Jul-12 0:50am
v3
Comments
ZurdoDev 23-Jul-12 10:30am    
Have you asked Telerik or checked their forums?
kevin_ze 24-Jul-12 0:49am    
I have checked their forums but am not able to find any solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900