We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How can I put Validation on MVC Grid

Thread ID:

Created:

Updated:

Platform:

Replies:

106430 Jan 7,2013 10:19 AM UTC Jan 8,2013 06:55 AM UTC ASP.NET MVC (Classic) 1
loading
Tags: Grid
Muhammad
Asked On January 7, 2013 10:19 AM UTC

how can I put required field Validation and compare field validation on syncfusion mvc Editable Grid 



Eswari S [Syncfusion]
Replied On January 8, 2013 06:55 AM UTC

Hi Muhammad,
 
Thank you for using Syncfusion products.
 
Your requirement of adding validation to the grid editing can be achieved. Please refer to the following steps to achieve your requirement.
 
Step #1: Add the following scripts for validation
 
    <script src="<%= Url.Content("~/Scripts/MicrosoftMvcValidation.debug.js") %>" type="text/javascript"></script>  
    <script src="<%= Url.Content("~/Scripts/jquery.unobtrusive-ajax.min.js") %>" type="text/javascript"></script>  
    <script src="<%= Url.Content("~/Scripts/jquery.validate.min.js") %>" type="text/javascript"></script>  
    <script src="<%= Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js") %>" type="text/javascript"></script>    
 
Step #2: Set ClientValidationEnabled and UnobtrusiveJavaScriptEnabled as true in web.config.
 
<configuration
  ….  
  <appSettings>
    <add key="ClientValidationEnabled" value="true"/>
    <add key="UnobtrusiveJavaScriptEnabled" value="true"/>
. . 
  </appSettings>
</configuration
 
Step #3: set validation attributes to the grid columns fields
 
 public class EditableCompanyShare
    {
         [Required(ErrorMessage = "CurrentRate is required.")]
        public Int32 CurrentRate
        {
            get;
            set;
        }
         [Compare("CurrentRate", ErrorMessage = "Predicted Rate should be equal to Current Rate")]
         public Int32 PredictedRate
         {
             get;
             set;
         }
    }
 
 
For your reference , we have prepared the sample and the same can be downloaded from the following link:
 

http://www.syncfusion.com/downloads/Support/DirectTrac/102431/Sample2047884833.zip

 
Please try this and let us know if you have any queries.
 
Regards,
Eswari S

               


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;