I am new at Telerik.
I would like to validate data that are in my radgridview,. If data are saved in the database they must be highlighted orange. The radgriview in my form does not have any columns before I run the application. The columns are developed programmatically and the radgridview bound at runtime.
How can I validate the columns?
I have tried the following code but it does not work.
Can you tell me what I am doing wrong?
Thank you in advance
void RadGridView_CellValidating(object sender, Telerik.WinControls.UI.CellValidatingEventArgs e){
var column = e.Column as GridViewDataColumn;
if (e.Row is GridViewDataRowInfo && column != null && column.Name == "Name")
{
var Value = (string)e.Value;
var Row = (GridViewDataRowInfo)e.Row;
if (string.IsNullOrEmpty((string)e.Value) || ((string)e.Value).Trim() == string.Empty)
{
e.Cancel = true;
((GridViewDataRowInfo)e.Row).ErrorText = "Validation error!";
}
else
{
((GridViewDataRowInfo)e.Row).ErrorText = string.Empty;
}
}
}