I've seen a ton of questions on this, however no simple explanations why this is occurring or what the solution to the problem is.
We've got a Batch Edit Update Grid that I originally had a RadComboBox in that was working fine until I found that keyboard navigation was screwing up the keyboard flow and saw that it was recommended to switch to a RadDropDown control, so I did, which is in a GridTemplateColumn similar to this:
<
telerik:RadGrid
ID
=
"RadGrdActionInputs"
runat
=
"server"
Width
=
"900px"
OnNeedDataSource
=
"RadGrdActionGroupInputs_NeedDataSource"
AutoGenerateColumns
=
"False"
RenderMode
=
"Lightweight"
AllowSorting
=
"True"
OnItemDataBound
=
"RadGrdActionInputs_ItemDataBound"
oninsertcommand
=
"RadGrdActionInputs_InsertCommand"
onupdatecommand
=
"RadGrdActionInputs_UpdateCommand"
ondeletecommand
=
"RadGrdActionInputs_DeleteCommand"
oneditcommand
=
"RadGrdActionInputs_EditCommand"
AutoGenerateEditColumn
=
"True"
>
<
GroupingSettings
CollapseAllTooltip
=
"Collapse all groups"
></
GroupingSettings
>
<
MasterTableView
CommandItemDisplay
=
"TopAndBottom"
DataKeyNames
=
"ID"
EditMode
=
"Batch"
>
<
BatchEditingSettings
EditType
=
"Row"
/>
<
CommandItemSettings
ShowCancelChangesButton
=
"true"
ShowRefreshButton
=
"false"
/>
....
<
telerik:GridTemplateColumn
HeaderText
=
"Data Point"
DataField
=
"DataPointID"
HeaderStyle-Width
=
"500px"
>
<
ItemTemplate
>
<
telerik:RadTextBox
ID
=
"RadTextBox1"
runat
=
"server"
Width
=
"150px"
></
telerik:RadTextBox
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadDropDownList
RenderMode
=
"Lightweight"
ID
=
"ddDataPointList"
runat
=
"server"
Width
=
"300px"
>
</
telerik:RadDropDownList
>
</
EditItemTemplate
>
<
HeaderStyle
Width
=
"500px"
></
HeaderStyle
>
</
telerik:GridTemplateColumn
>
In the examples and the problems/posts that I have seen, they all recommend checking the e.item type in the ItemDataBound event. If the e.item is a GridDataItem then bind a label, else if it's a GridEditableItem bind the dropdown, IE:
protected
void
RadGrdActionInputs_ItemDataBound(
object
sender, GridItemEventArgs e)
{
//get combobox data for drop down.
DataPointsModel dataPointsModel = ConfigurationController.GetAllDataPoints();
try
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = (GridDataItem)e.Item;
RadLabel lblActionGroupType = item.FindControl(
"lblDataPoint"
)
as
RadLabel;
//get value for ActionGroupTypeID
string
val = DataBinder.Eval(item.DataItem,
"DataPointID"
).ToString();
}
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
RadDropDownList rddl = item.FindControl(
"ddDataPointList2"
)
as
RadDropDownList;
BindRadDropDownDataList(
"I"
, rddl,
"Name"
,
"ID"
);
}
}
catch
{}
}
Problem is, this code never gets called:
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
RadDropDownList rddl = item.FindControl(
"ddDataPointList2"
)
as
RadDropDownList;
BindRadDropDownDataList(
"I"
, rddl,
"Name"
,
"ID"
);
}
I'm pulling my hair out on this one..