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

[Solved] Edit Mode (Inline) Validation

1 Answer 71 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Haseeb
Top achievements
Rank 1
Haseeb asked on 20 Mar 2013, 09:57 PM
Hi,
    Can any one tell me , How can i Validate the Record in grid during Edit Mode (Inline).   Note, I am not using Template Edit Form
   I am creating everything in Code Behind even BoundColumn .

Thanks

1 Answer, 1 is accepted

Sort by
0
J
Top achievements
Rank 1
answered on 21 Mar 2013, 01:48 AM
As long as you're still wiring up the events on the grid you could use this from the help page:

protected void RadGrid1_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        GridEditableItem item = e.Item as GridEditableItem;
        GridTextBoxColumnEditor editor = (GridTextBoxColumnEditor)item.EditManager.GetColumnEditor("ContactName");
        TableCell cell = (TableCell)editor.TextBoxControl.Parent;
 
        RequiredFieldValidator validator = new RequiredFieldValidator();
        editor.TextBoxControl.ID = "ID_for_validation";
        validator.ControlToValidate = editor.TextBoxControl.ID;
        validator.ErrorMessage = "*";
        cell.Controls.Add(validator);
    }
}

I'm pretty sure with a few tweaks you could do that during your column creation instead.
Tags
Grid
Asked by
Haseeb
Top achievements
Rank 1
Answers by
J
Top achievements
Rank 1
Share this question
or