or
I can read the value of "grid column drop down"in the method "OnEditCommandRadGridProgramCategory. About e.Item.FindControl is null and also against the direct access via "GridDropDownColumnVirtualCategory.DataValueField" is null.
The call to the method is via "CommandName = EditSelected.
Can you help me please?
<telerik:RadGrid ID=
"RadGridProgramCategory"
AutoGenerateColumns=
"false"
AllowAutomaticInserts=
"True"
AllowAutomaticUpdates=
"True"
AllowAutomaticDeletes=
"True"
OnEditCommand=
"OnEditCommandRadGridProgramCategory"
OnNeedDataSource=
"OnNeedDataSourceRadGridProgramCategory"
GridLines=
"None"
runat=
"server"
Width=
"350px"
>
<Columns>
<telerik:GridDropDownColumn HeaderText=
"Hauptkategorie"
ColumnEditorID=
"GridDropDownColumnVirtualCategory"
ListDataMember=
"VirtualCategoryId"
UniqueName=
"VirtualCategoryId"
DataField=
"VirtualCategoryId"
ListTextField=
"VirtualCategoryName"
ListValueField=
"VirtualCategoryId"
/>
<telerik:GridDropDownColumn HeaderText=
"Unterkategorie"
ColumnEditorID=
"GridDropDownColumnCategory"
ListDataMember=
"CategoryId"
UniqueName=
"CategoryId"
DataField=
"CategoryId"
ListTextField=
"CategoryName"
ListValueField=
"CategoryId"
/>
<telerik:GridEditCommandColumn ButtonType=
"ImageButton"
UniqueName=
"EditCommandColumn"
/>
</Columns>
</MasterTableView>
</telerik:RadGrid>
<telerik:GridDropDownListColumnEditor ID=
"GridDropDownColumnVirtualCategory"
runat=
"server"
DropDownStyle-Width=
"110px"
/>
<telerik:GridDropDownListColumnEditor ID=
"GridDropDownColumnCategory"
runat=
"server"
DropDownStyle-Width=
"110px"
/>
protected
void
OnEditCommandRadGridProgramCategory(
object
sender, GridCommandEventArgs e)
{
RadGrid radGrid = (RadGrid)sender;
Control s0 = e.Item.FindControl(GridDropDownColumnVirtualCategory.ClientID);
string
s1 = GridDropDownColumnVirtualCategory.DataValueField;
string
s2 = GridDropDownColumnCategory.DataValueField;
}
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
CssClass
=
"RadGrid"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
ShowStatusBar
=
"true"
OnPreRender
=
"RadGrid1_PreRender"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
OnUpdateCommand
=
"RadGrid1_UpdateCommand"
OnInsertCommand
=
"RadGrid1_InsertCommand"
OnDeleteCommand
=
"RadGrid1_DeleteCommand"
>
<
MasterTableView
Width
=
"100%"
CommandItemDisplay
=
"Top"
DataKeyNames
=
"EmployeeID"
>
<
CommandItemTemplate
>
<
telerik:RadToolBar
ID
=
"RadToolBar1"
OnButtonClick
=
"RadToolBar1_ButtonClick"
runat
=
"server"
OnClientButtonClicking
=
"onToolBarClientButtonClicking"
>
<
Items
>
<
telerik:RadToolBarButton
Text
=
"Edit selected"
CommandName
=
"EditSelected"
ImageUrl
=
"~/ToolBar/Examples/ApplicationScenarios/GridCommandItem/Images/Edit.gif"
Visible='<%# RadGrid1.EditIndexes.Count == 0 %>'></
telerik:RadToolBarButton
>
<
telerik:RadToolBarButton
Text
=
"Update"
CommandName
=
"UpdateEdited"
ImageUrl
=
"~/ToolBar/Examples/ApplicationScenarios/GridCommandItem/Images/Update.gif"
Visible='<%# RadGrid1.EditIndexes.Count > 0 %>'></
telerik:RadToolBarButton
>
<
telerik:RadToolBarButton
Text
=
"Cancel editing"
CommandName
=
"CancelAll"
ImageUrl
=
"~/ToolBar/Examples/ApplicationScenarios/GridCommandItem/Images/Cancel.gif"
Visible='<%# RadGrid1.EditIndexes.Count > 0 || RadGrid1.MasterTableView.IsItemInserted %>'></
telerik:RadToolBarButton
>
<
telerik:RadToolBarButton
Text
=
"Add new"
CommandName
=
"InitInsert"
ImageUrl
=
"~/ToolBar/Examples/ApplicationScenarios/GridCommandItem/Images/AddRecord.gif"
Visible='<%# !RadGrid1.MasterTableView.IsItemInserted %>'></
telerik:RadToolBarButton
>
<
telerik:RadToolBarButton
Text
=
"Add this Customer"
CommandName
=
"PerformInsert"
ImageUrl
=
"~/ToolBar/Examples/ApplicationScenarios/GridCommandItem/Images/Insert.gif"
Visible='<%# RadGrid1.MasterTableView.IsItemInserted %>'></
telerik:RadToolBarButton
>
<
telerik:RadToolBarButton
Text
=
"Delete selected customers"
CommandName
=
"DeleteSelected"
ImageUrl
=
"~/ToolBar/Examples/ApplicationScenarios/GridCommandItem/Images/Delete.gif"
></
telerik:RadToolBarButton
>
<
telerik:RadToolBarButton
Text
=
"Refresh customer list"
CommandName
=
"RebindGrid"
ImageUrl
=
"~/ToolBar/Examples/ApplicationScenarios/GridCommandItem/Images/Refresh.gif"
></
telerik:RadToolBarButton
>
</
Items
>
</
telerik:RadToolBar
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn"
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"TitleOfCourtesy"
HeaderText
=
"TOC"
DataField
=
"TitleOfCourtesy"
>
<
HeaderStyle
Width
=
"60px"
></
HeaderStyle
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"FirstName"
HeaderText
=
"FirstName"
DataField
=
"FirstName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"LastName"
HeaderText
=
"LastName"
DataField
=
"LastName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"HireDate"
HeaderText
=
"Hire Date"
DataField
=
"HireDate"
DataFormatString
=
"{0:d}"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Title"
HeaderText
=
"Title"
DataField
=
"Title"
>
</
telerik:GridBoundColumn
>
<
telerik:GridButtonColumn
UniqueName
=
"DeleteColumn"
Text
=
"Delete"
CommandName
=
"Delete"
/>
</
Columns
>
<
EditFormSettings
UserControlName
=
"EmployeeDetailsCS.ascx"
EditFormType
=
"WebUserControl"
>
<
EditColumn
UniqueName
=
"EditCommandColumn1"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"True"
EnableDragToSelectRows
=
"False"
/>
<
ClientEvents
OnRowDblClick
=
"RowDblClick"
/>
</
ClientSettings
>
</
telerik:RadGrid
>
protected
void
grd_list_ItemDataBound(
object
sender, Telerik.Web.UI.GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && (e.Item
as
GridEditableItem).IsInEditMode)
{
GridEditableItem editedItem = e.Item
as
GridEditableItem;
GridEditManager editMan = editedItem.EditManager;
GridDropDownListColumnEditor editor = (GridDropDownListColumnEditor)(editMan.GetColumnEditor(
"StatusUniqueName"
));
//Ativo' WHEN STATUS = 'P' THEN 'Pausado' WHEN STATUS = 'F' THEN 'Finalizado
ArrayList ds =
new
ArrayList();
ds.Add(
new
status(
"A"
,
"Ativar"
));
ds.Add(
new
status(
"P"
,
"Pausar"
));
ds.Add(
new
status(
"F"
,
"Finalizar"
));
//string val = oMonitor.ExecuteScalarString("select STATUS from MAILING WHERE ID = " + editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["Id"]);
string
s = DataBinder.Eval(editedItem.DataItem,
"StatusValue"
).ToString();
//the field should point to the ListValueField of the dropdown editor
editor.DataSource = ds;
editor.DataTextField =
"Status"
;
editor.DataBind();
editor.SelectedValue = s;
}
<
telerik:GridDropDownColumn
UniqueName
=
"StatusUniqueName"
ListDataMember
=
"Status"
ListTextField
=
"Status"
ListValueField
=
"StatusValue"
DataField
=
"StatusValue"
HeaderText
=
"Status"
>
</
telerik:GridDropDownColumn
>
grd_list_ItemDataBound
:public
class
status
{
private
string
_value;
private
string
_text;
public
status(
string
value,
string
text)
{
_value = value;
_text = text;
}
public
string
Status
{
get
{
return
_text; }
set
{ _text = value; }
}
public
string
StatusValue
{
get
{
return
_value; }
set
{ _value = value; }
}
};