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

validate the DropDownList control inside built-in GridDropDownColumn.

1 Answer 64 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Rahul Barpha
Top achievements
Rank 1
Rahul Barpha asked on 07 May 2010, 08:44 AM
Hello Friend's

How to validate the DropDownList control inside built-in GridDropDownColumn.
i am not want to use gridtemplatecolumn

 

 

 


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 07 May 2010, 11:22 AM
Hello Rahul,

You can get reference to the GridDropdownColumn in the ItemdataBound event and get the editor for the dropdown. Access the cell as shown in the code snippet and assign the validator accordingly. It would be a good idea to use Custom validator for validation.

C#:
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)  
{  
        if (e.Item is GridEditableItem && e.Item.IsInEditMode)  
        {  
            GridEditableItem item = e.Item as GridEditableItem;  
            DropDownList dropDownList1 = item["UserName"].Controls[0] as DropDownList;  
            GridDropDownColumnEditor editor=(GridDropDownColumnEditor)item.EditManager.GetColumnEditor("UserName");  
            TableCell cell = (TableCell)editor.ContainerControl;             
            //Declare the validator   
            //Add the validator to the cell  
            //cell.Controls.Add(validator);   
}  
Also checkout the following documentation to know more about this:
Adding a validator to an edit field in Telerik RadGrid

Regards,
Shinu.
Tags
Grid
Asked by
Rahul Barpha
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or