I have a very annoying problem with validating a column in a RadGrid. In edit mode(IN PLACE) I want a column to be validated when pressing image button for submit.
The problem is that my GridTextBoxColumnEditor is moved upwards just to make space for the error message IF the validation fails. So when the edit form is loaded the controls have different vertical position. I think it should be possible to move the GridTextBoxColumnEditor upwards and show the message ONLY if the validation fails. Then all the controls get the right alignment. I have tried to create the validator in the InsertCommand event but that didn't work. Down below you can see my code:
protected void gridReports_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem editedItem = e.Item as GridEditableItem;
GridTextBoxColumnEditor editor = null;
if (editedItem["description"].Text == " ")
{
editor = (GridTextBoxColumnEditor)editedItem.EditManager.GetColumnEditor("description");
TableCell cell = (TableCell)editor.TextBoxControl.Parent;
RequiredFieldValidator validator = new RequiredFieldValidator();
validator.ControlToValidate = editor.TextBoxControl.ID;
validator.ErrorMessage = "Field is mandatory!";
cell.Controls.Add(validator);
}
Do you guys have any suggestions?