Hi Rodrigo,
Thanks for Syncfusion product.
In GridDataBoundGrid can populate the columns automatically based on the bounded collection underlying datasource but does not have the direct support for Data Annotation. But, you can achieve your scenario by using HeaderText property. Please refer to the below code example
Code example
Using System.ComponentModel.DataAnnotations;
[Display(Name = "Category Name")]
public string CategoryName
{
get
{
return this.cat_Name;
}
set
{
this.cat_Name = value;
}
}
Data d = new Data();
foreach (GridBoundColumn column in columns)
{
var col = (d.GetType().GetProperty(column.MappingName)).GetCustomAttributes(typeof(DisplayAttribute), true);
if (col is DisplayAttribute[] && (col as DisplayAttribute[]).Count() > 0)
{
string headerText = (col as DisplayAttribute[])[0].Name;
column.HeaderText = headerText;
}
} |
Note:
Moreover, you can use GridGroupingControl instead of GridDataboundGrid. GridGroupingControl has more features and more flexibility compared to GridDataBoundGrid.
Regards,
Mohanraj G