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

Cell validation and localization

1 Answer 61 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kornelije
Top achievements
Rank 1
Kornelije asked on 06 Jul 2012, 01:33 PM

I have a business object with three columns (int year, int month and double value) bound to the GridView.

When the user adds a new row or edits an existing one, some cell validation takes place. 

This is an example property of the business object

private int month;
public int Month
{
    get
    {
        return month;
    }
    set
    {
        try
        {
            if (month == value)
                return;
  
            month = value;
            Time = new DateTime(t.Year, value, t.Day, t.Hour, t.Minute, t.Second);  
  
            onPropertyChanged("Month");
  
        }
        catch
        {
            throw new InvalidOperationException(Strings.MonthInvalid);
        }
    }
}

When the user enters 13 or something else that is not a valid month number, the "new DateTime()" call will throw an exception which will be caught, and then in turn, a new exception will be thrown and the message will be shown to the user in a nice red tooltip.

However, if I enter something like 1354684635135746876510, the control will be unable to fit that into my integer property so the Exception with the message "Input is not in a correct format" will be thrown. The message is in English, and I need to localize this. Obviously I can't edit .NET's exceptions (nor should I). But how can I solve this? I'd like to be able to validate the cells with my own messages supplied, no matter what is entered. Is this possible?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 06 Jul 2012, 01:55 PM
Hello Kornelije,

I would recommend you to run through this blog post for a reference. 

Regards,
Maya
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
GridView
Asked by
Kornelije
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or