Hi there-
I am struggling to figure out how to do this task. I have a RadGrid with several bound GridDropDownColumns and am trying to do some server side validation when a user clicks Edit to check if the current value is valid. Since these rows may not match a good value, I want to highlight the border of the cell when it is invalid, even though the default behavior of GridDropDownColumns selects a default value when none is given.
Here is the page code:
Here is the code behind:
as you can see I have tried many options but haven't been able to get the behavior I desire. I am looking to have the same styling as if I were to set the ItemStyle-BorderColor="RED" on the object like this:
how can i accomplish this?
thanks for any help!
I am struggling to figure out how to do this task. I have a RadGrid with several bound GridDropDownColumns and am trying to do some server side validation when a user clicks Edit to check if the current value is valid. Since these rows may not match a good value, I want to highlight the border of the cell when it is invalid, even though the default behavior of GridDropDownColumns selects a default value when none is given.
Here is the page code:
<
telerik:RadGrid
ID
=
"RadGrid1"
GridLines
=
"None"
runat
=
"server"
CssClass
=
"AutoShrink"
AllowPaging
=
"True"
AllowAutomaticUpdates
=
"True"
PagerStyle-AlwaysVisible
=
'true'
AutoGenerateColumns
=
"False"
DataSourceID
=
"AutoInventory_OUStaging_DataSource"
OnItemUpdated
=
"RadGrid1_ItemUpdated"
OnItemDeleted
=
"RadGrid1_ItemDeleted"
OnItemInserted
=
"RadGrid1_ItemInserted"
OnDataBound
=
"RadGrid1_DataBound"
OnItemDataBound
=
"RadGrid1_ItemDataBound"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
Skin
=
"Sunset"
AllowSorting
=
"True"
PageSize
=
"15"
>
Here is the code behind:
protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
{
if (e.Item is GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item as GridEditableItem;
GridEditManager editMan = item.EditManager;
GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor("DataCenterCode"));
//DropDownList ddList = editor.DropDownListControl;
editor.DropDownStyle.BorderColor = Color.Red;
editor.DropDownStyle.BorderStyle = BorderStyle.Solid;
//ddList.Items[0].Attributes["style"] = "color: red";
// item["DataCenterCode"].BorderColor = Color.Red;
//item["DataCenterCode"].CssClass = "invalidfield";
//item["DataCenterCode"].ControlStyle.BorderColor = Color.Red;
//// We can get the id of the edit record by
//GridEditManager editMan = item.EditManager;
//GridDropDownListColumnEditor editor = editMan.GetColumnEditor("DataCenterCode") as GridDropDownListColumnEditor;
//editor.DropDownStyle.BorderColor = Color.Red;
//list.BorderColor = Color.Red;
//GridDataItem item = (GridDataItem)e.Item;
//Literal litrl = (Literal)item["DataCenterCode"].Controls[0];
//int updateId = Convert.ToInt32(item.GetDataKeyValue("ServerId"));
// now write code for binding row data in the interface
}
}
as you can see I have tried many options but haven't been able to get the behavior I desire. I am looking to have the same styling as if I were to set the ItemStyle-BorderColor="RED" on the object like this:
<
telerik:GridDropDownColumn
DataField
=
"DataCenterCode"
DataSourceID
=
"SqlDataSource_DataCenters"
HeaderText
=
"DataCenterCode"
ListTextField
=
"Acronym"
ListValueField
=
"Acronym"
UniqueName
=
"DataCenterCode"
ColumnEditorID
=
"GridDropDownColumnEditor2"
ItemStyle-BorderColor
=
"Red"
>
</
telerik:GridDropDownColumn
>
how can i accomplish this?
thanks for any help!