I have successfully added a RequiredFieldValidator on my grid, whose EditMode="InPlace":
I know my code is convaluted, but basically its correctly adding a RequiredFieldValidator when you click insert. But not sure why, its now not putting an identical RequiredfieldValidator when I click 'Edit'? I would think it would roughly be the same code.
J
if ((e.Item is GridDataInsertItem) && e.Item.IsInEditMode) |
{ |
// Insert is clicked |
GridEditableItem editedItem = e.Item as GridEditableItem; |
GridDataItem dataItem = (GridDataItem)e.Item; |
GridEditManager editMan = editedItem.EditManager; |
GridDropDownListColumnEditor editor = editMan.GetColumnEditor("Id") as GridDropDownListColumnEditor; |
RadComboBox dropDownList1 = editedItem["Id"].Controls[0] as RadComboBox; |
TableCell cell = (TableCell)editor.ContainerControl; |
//Declare the validator |
RequiredFieldValidator rfv = new RequiredFieldValidator(); |
rfv.ControlToValidate = dropDownList1.ID; |
rfv.ID = "valId"; |
rfv.ErrorMessage = @"<img src='Images/cautionIcon.png' class='Validation' />"; |
//Add the validator to the cell |
cell.Controls.Add(rfv); |
editor.ComboBoxControl.Skin = "MySkin"; |
editor.ComboBoxControl.EnableEmbeddedSkins = false; |
editor.ComboBoxControl.DropDownWidth = Unit.Pixel(500); |
editor.ComboBoxControl.Width = Unit.Pixel(380); |
var erds = (from result in _s |
where !_Ds.Any(dto => |
dto.Id == result.SystemID) |
select result).ToList<DTO>(); |
editor.DataSource = s; |
editor.DataBind(); |
} |
else if ((e.Item is GridEditableItem) && e.Item.IsInEditMode) |
{ |
// Edit is clicked |
GridEditableItem editedItem = e.Item as GridEditableItem; |
GridDataItem dataItem = (GridDataItem)e.Item; |
DTO affected = (DTO)e.Item.DataItem; |
GridEditManager editMan = editedItem.EditManager; |
GridDropDownListColumnEditor editor = editMan.GetColumnEditor("Id") as GridDropDownListColumnEditor; |
RadComboBox dropDownList1 = editedItem["Id"].Controls[0] as RadComboBox; |
TableCell cell = (TableCell)editor.ContainerControl; |
//Declare the validator |
RequiredFieldValidator rfv = new RequiredFieldValidator(); |
rfv.ControlToValidate = dropDownList1.ID; |
rfv.ID = "Id"; |
rfv.ErrorMessage = @"<img src='Images/cautionIcon.png' class='Validation' />"; |
editor.ComboBoxControl.Skin = "EPSS"; |
editor.ComboBoxControl.EnableEmbeddedSkins = false; |
editor.ComboBoxControl.DropDownWidth = Unit.Pixel(500); |
editor.ComboBoxControl.Width = Unit.Pixel(380); |
var erds = (from result in _s |
where !_as.Any(dto => |
dto.Id == result.SystemID && dto.Id != affected.Id) |
select result).ToList<DTOSystem>(); |
editor.DataSource = s; |
editor.DataBind(); |
editor.SelectedValue = affected.Id.ToString(); |
} |
I know my code is convaluted, but basically its correctly adding a RequiredFieldValidator when you click insert. But not sure why, its now not putting an identical RequiredfieldValidator when I click 'Edit'? I would think it would roughly be the same code.
J