Hello ,
I want to add some validates at bounded columns , I tried hardly to let it work but I failed so please help me in this issue :-first of all i have grid has 4 Bounded column
<telerik:GridBoundColumn DataField="EmployerName" HeaderText="Employer Name" UniqueName="EmployerName"/>
<telerik:GridBoundColumn DataField="Position" HeaderText="Position" UniqueName="Position" />
<telerik:GridDateTimeColumn DataField="FromDT" HeaderText="From" UniqueName="FromDT" />
<telerik:GridDateTimeColumn DataField="ToDT" HeaderText="To" UniqueName="ToDT"/>
I need to add 4 required validation on these column
I registered ItemCreated event and tried to add validations like that
protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item as GridEditableItem;
RequiredFieldValidator validator1 = new RequiredFieldValidator();
validator1.ID = "validator1";
validator1.ErrorMessage = " * " ;
(item["EmployerName"].Controls[0] as TextBox).ID = item.ClientID + "_TextBox";
validator1.ControlToValidate = (item["EmployerName"].Controls[0] as TextBox).ID;
item["EmployerName"].Controls.Add(validator1);
}
}
Vaildators worked well but at insert or update event handler after called extract values method , I figured that the value for the EmployerName and Position columns was always equal null and other have values.
item.ExtractValues(newValues); // newValues["EmployerName"] , Although I entered value in the edit form
after that I tried to add the Vaildators at item data bound event but it is still the same and the values returned null also.
I think when I changed the id of the item[ColumnUniqueName].control[0] the extract item didn't work well .