This is a migrated thread and some comments may be shown as answers.

Data Annotation Issue

2 Answers 129 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Matthias
Top achievements
Rank 1
Matthias asked on 10 Dec 2010, 02:10 PM
Hi telerik Team

It seems that DataAnnotations don't work in RadControls_for_WPF35_2010_3_1110_Trial.

I build a Testclass and set it as ItemSource on GridView but except DisplayName all attributes are ignored.

public class Test
{
    [Display(AutoGenerateField = false)]
    [RangeAttribute(1, 10)]
    public int Id { get; set; }
 
    [DisplayName("TestNumber")]
    [Display(Order = 1)]
    [Required(AllowEmptyStrings = false, ErrorMessage = "Exception")]
    public string Number { get; set; }
 
    [Display(Order = 0)]
    [Required(AllowEmptyStrings = false, ErrorMessage = "Exception")]
    public string Name { get; set; }
}

List<Test> testList = new List<Test>();
 
Test test = null;
for (int i = 0; i < 10; i++)
{
    test = new Test();
    test.Id = i;
    test.Name = "Name" + i.ToString();
    test.Number = i.ToString();
    testList.Add(test);
}
 
radGridView.ItemsSource = testList;

Your artikel here say it should work:
http://www.telerik.com/help/wpf/gridview-prevent-column-autogenerate.html
http://www.telerik.com/products/wpf/gridview.aspx#built-in-data-validation

What i'm doing wrong?

PS: I also try 00968RadControls_for_WPF_40_2010_3_1206_TRIAL_hotfix

PPS: It would great if user could add Sample VS Project to posts, not just images.

2 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 10 Dec 2010, 02:23 PM
Hi,

Please use our .NET 4.0 build if you want support for Data Annotations -  these are not available in .NET 3.5.
Please use also Display instead DisplayName. DisplayName is the old way which is now replaced with Data Annotations Display attribute. 

You can check the attached project for reference.

You can attach projects only in our support tickets - not in our forums.  

Best wishes,
Vlad
the Telerik team
Browse the videos here>> to help you get started with RadControls for WPF
0
Matthias
Top achievements
Rank 1
answered on 13 Dec 2010, 11:33 AM
Thanks, as you mentioned NET 4.0 build was the trick.
Tags
GridView
Asked by
Matthias
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Matthias
Top achievements
Rank 1
Share this question
or