Print Page | Close Window

Displaying validation errors in DataGrid (Silverlight)

Printed From: IdeaBlade
Category: DevForce
Forum Name: DevForce 2010
Forum Discription: For .NET 4.0
URL: http://www.ideablade.com/forum/forum_posts.asp?TID=3997
Printed Date: 07-Sep-2025 at 7:18am


Topic: Displaying validation errors in DataGrid (Silverlight)
Posted By: katit
Subject: Displaying validation errors in DataGrid (Silverlight)
Date Posted: 20-Feb-2013 at 6:36pm
Trying to come up with best strategy for DataGrid entry validation
 
Using DevForce verification features.
 
1. When dataentry happens in a grid and entity has "immediate" validation (on property set) - I get feedback and it is all nice.
 
When I run verification LATER (before save) and need to check for duplicates in grid (for example) I don't get visual clues. From what I learned - DataGrid shows validation errors only while in edit mode and it actually locks you on that bad row. So, if I run verification and don't get any "red" on DataGrid I can go into grid, click into bad row and get this validation error.
 
Obviously this is not what I'm after. I want datagrid to reflect validation problem right away. Is there any tips on that? Any tips working with DataGrid?
 
2. I tried something different. I thought that since entities implement INotifyDataErrorInfo I will just bind something to HasErrors property. I created column in a grid with "error" icon and set it's visibility to show when HasErrors set. It didn't work either, for some reason it can't bind to it (doesn't see this property). I can get to it by casting to INotifyDataErrorInfo but can't figure out how to do it nicely. What I did now is I exposed property "HasErrors" in partial class and flip it on/off during validation. This way it highlights DataGrid row by showing icon.
 
I don't like this solution...
 
Is there any better/best way to deal with data entry in a grid?



Replies:
Posted By: sbelini
Date Posted: 26-Feb-2013 at 4:49pm
Hi katit,

I found this article that might help you with what you are looking for: ( although I feel your approach is going thru the same route)

http://geekswithblogs.net/lorilalonde/archive/2011/10/29/silverlight-4-datagridndashbulk-validation-using-inotifydataerrorinfo.aspx - http://geekswithblogs.net/lorilalonde/archive/2011/10/29/silverlight-4-datagridndashbulk-validation-using-inotifydataerrorinfo.aspx




Print Page | Close Window