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. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Retrieve Header Text from Data Annotations on Model

Thread ID:

Created:

Updated:

Platform:

Replies:

108690 May 7,2013 03:50 PM UTC Apr 10,2019 11:15 AM UTC ASP.NET MVC (Classic) 3
loading
Tags: Grid
Mike McCaughan
Asked On May 7, 2013 03:50 PM UTC

One thing that's nice about the built-in HTML Helpers like LabelFor() is that it pulls its text from the Display() Data Annotation attribute if supplied. I had assumed that the Grid would do that for the HeaderText, but I'm not seeing that happening. Is there an easy way of making that happen, or shall I create a Feature Request for it?

Rakesh D [Syncfusion]
Replied On May 14, 2013 10:48 AM UTC

 

Hi Mike,

 

Thank you for using Syncfusion products.

 

Query : Retrieve Header Text from Data Annotations on Model ?

 

We would like to let you know that you can display the HeaderText for a column in Grid by defining the Display() Data Annotation attribute in model. Please refer below code snippet for further details.

 

[Display(Name = "Duration in Hrs")]

        public int Duration { get; set; }

 

For your convenience we have prepared a sample for the above scenario and it is attached below. Please refer to it.

 

Could you please let us know whether this is the requirement you wanted to achieve using Display of Data Annotation ? If not could you please provide us more information on your requirement so that we could sort out the issue and provide you the solution for it. The information provided would be of great help in resolving your issue.

  

Please let us know if you have any concerns.

 

Regards,

Rakesh D

 



GridSample Header Text_3c3d2610.zip

Hasan Kosten
Replied On April 9, 2019 11:39 AM UTC

The specified example file does not exist. 

Vignesh Natarajan [Syncfusion]
Replied On April 10, 2019 11:15 AM UTC

Hi Haasan, 
  
Thanks for using Syncfusion Products. 
 
Grid MVC will support Data annotation attributes. Please refer to the following code snippets: 
 
[EditableOrder.cs] 
public class EditableOrder 
{ 
// Validation set to the orderId and customerId 
[Required(ErrorMessage = "Order ID is required.")] 
public int OrderID 
{ 
get; 
set; 
} 
[Required(ErrorMessage = "Customer  ID is required.")] 
[StringLength(5, ErrorMessage = "Customer ID must be 5 characters.")] 
public string CustomerID 
{ 
get; 
set; 
} 
.. . . 
} 
 
 
Add the following script files to your layout.cs within the head tag. Please refer to the following code snippets: 
 
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> 
  
       <script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.js")" type="text/javascript"></script> 
 
 
We have prepared the sample for your requirement and the same can be downloaded from the following link: 
 
 
Please get back to us if you have further queries. 
 
Regards, 
Vignesh Natarajan. 
 


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

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

;