Hello,
I've a grid with Batch Edit Mode enabled, In this grid I have a Template column that contains a RadComboBox with Checkboxes enabled, The issue is once the save changes button is cliked and the page posts back, I cannot find a way to get the Checked checkboxes collection. Im trying to achieve this by using BatchEditCommand method.
Is there anyway to achieve this??
My grid looks like this:
and below my code behind scenes :D
for statements are never happening since Item.checked and CheckedItems count is always Zero.
Any help would be greatly appreciated.
Thks in advance.
I've a grid with Batch Edit Mode enabled, In this grid I have a Template column that contains a RadComboBox with Checkboxes enabled, The issue is once the save changes button is cliked and the page posts back, I cannot find a way to get the Checked checkboxes collection. Im trying to achieve this by using BatchEditCommand method.
Is there anyway to achieve this??
My grid looks like this:
<
telerik:RadGrid
runat
=
"server"
ID
=
"gv_ItemGrid"
PageSize
=
"50"
Skin
=
"Office2007"
AllowSorting
=
"true"
AllowMultiRowSelection
=
"true"
AllowMultiRowEdit
=
"true"
AllowPaging
=
"True"
ShowGroupPanel
=
"false"
HeaderStyle-HorizontalAlign
=
"Center"
ClientSettings-AllowKeyboardNavigation
=
"true"
AutoGenerateColumns
=
"false"
AllowAutomaticDeletes
=
"false"
AllowAutomaticInserts
=
"false"
AllowAutomaticUpdates
=
"false"
OnNeedDataSource
=
"gv_ItemGrid_NeedDataSource"
OnItemDataBound
=
"gv_ItemGrid_ItemDataBound"
OnBatchEditCommand
=
"gv_ItemGrid_BatchEditCommand"
>
<
PagerStyle
Mode
=
"NextPrevAndNumeric"
/>
<
ClientSettings
AllowRowsDragDrop
=
"False"
AllowColumnsReorder
=
"false"
ReorderColumnsOnClient
=
"false"
EnableRowHoverStyle
=
"true"
>
<
Resizing
AllowColumnResize
=
"false"
/>
<
Selecting
AllowRowSelect
=
"false"
EnableDragToSelectRows
=
"false"
/>
<
Scrolling
AllowScroll
=
"false"
UseStaticHeaders
=
"false"
/>
<
ClientEvents
OnBatchEditOpening
=
"batchEditOpening"
OnBatchEditOpened
=
"batchEditOpened"
/>
</
ClientSettings
>
<
MasterTableView
Name
=
"gv_Items"
CommandItemDisplay
=
"Top"
EditMode
=
"Batch"
DataKeyNames
=
"PK"
>
<
Columns
>
<
telerik:GridBoundColumn
UniqueName
=
"PK"
DataField
=
"PK"
HeaderText
=
"PK"
Display
=
"false"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"ItemCode"
DataField
=
"ItemCode"
HeaderText
=
"Item Code"
SortExpression
=
"ItemCode"
HeaderStyle-Width
=
"70px"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"Locations"
DataField
=
"Locations"
HeaderText
=
"Allocated to"
HeaderStyle-Width
=
"100px"
Display
=
"false"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"ItemDescription"
HeaderText
=
"Item Name"
DataField
=
"ItemDescription"
HeaderStyle-Width
=
"200px"
></
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"ManufactureDescription"
HeaderText
=
"Manufacture Description"
DataField
=
"ManufactureDescription"
HeaderStyle-Width
=
"100px"
></
telerik:GridBoundColumn
>
<
telerik:GridNumericColumn
UniqueName
=
"Cost"
HeaderText
=
"Cost"
DataField
=
"Cost"
NumericType
=
"Currency"
DecimalDigits
=
"2"
AllowRounding
=
"false"
HeaderStyle-Width
=
"60px"
></
telerik:GridNumericColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"CategoryIDs"
HeaderText
=
"Category Allocation"
HeaderStyle-Width
=
"300px"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblCategoryLine"
runat
=
"server"
Text='<%# Eval("CategoryIDs") %>' ></
asp:Label
>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
runat
=
"server"
EnableLoadOnDemand
=
"true"
ID
=
"RadComboBox1"
OnItemsRequested
=
"RadComboBox1_ItemsRequested"
DataTextField
=
"LineCatDesc"
DataValueField
=
"seq"
Skin
=
"Office2007"
MaxHeight
=
"120px"
Width
=
"400px"
CheckBoxes
=
"true"
EnableCheckAllItemsCheckBox
=
"true"
></
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridCheckBoxColumn
UniqueName
=
"active"
HeaderText
=
"Active"
DataField
=
"active"
ItemStyle-HorizontalAlign
=
"Center"
HeaderStyle-Width
=
"30px"
></
telerik:GridCheckBoxColumn
>
<
telerik:GridCheckBoxColumn
UniqueName
=
"isFilter"
Display
=
"false"
HeaderText
=
"Reports Filter"
DataField
=
"isFilter"
ItemStyle-HorizontalAlign
=
"Center"
></
telerik:GridCheckBoxColumn
>
<
telerik:GridButtonColumn
Visible
=
"true"
ConfirmText
=
"Delete this Item?"
ButtonType
=
"ImageButton"
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn"
>
<
HeaderStyle
Width
=
"30px"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridButtonColumn
>
</
Columns
>
<
CommandItemSettings
ShowRefreshButton
=
"false"
/>
</
MasterTableView
>
</
telerik:RadGrid
>
and below my code behind scenes :D
protected
void
gv_ItemGrid_BatchEditCommand(
object
sender, GridBatchEditingEventArgs e)
{
foreach
(GridBatchEditingCommand command
in
e.Commands)
{
if
(command.Type == GridBatchEditingCommandType.Update)
{
Hashtable newValues = command.NewValues;
Hashtable oldValues = command.OldValues;
RadComboBox ddlDesc = gv_ItemGrid.FindControl(gv_ItemGrid.MasterTableView.ClientID +
"_CategoryIDs"
).FindControl(
"RadComboBox1"
)
as
RadComboBox;
string
selectedValues = String.Empty;
if
(ddlDesc.CheckBoxes) {
for
(
int
i = 0; i < ddlDesc.CheckedItems.Count; i++)
{
selectedValues += (selectedValues == String.Empty)?(ddlDesc.CheckedItems[i]
as
RadComboBoxItem).Value:
","
+ (ddlDesc.CheckedItems[i]
as
RadComboBoxItem).Value;
}
}
for
(
int
i = 0; i < ddlDesc.Items.Count; i++)
{
selectedValues += (selectedValues == String.Empty) ? ((ddlDesc.Items[i].Checked)?ddlDesc.Items[i].Value:
string
.Empty) : ((ddlDesc.Items[i].Checked)?
","
+ (ddlDesc.CheckedItems[i]
as
RadComboBoxItem).Value:
string
.Empty);
selectedValues += ddlDesc.Items[i].Checked.ToString();
}
UBGlobal.SendEmail(
"Checkboxes Count"
, ddlDesc.Items.Count.ToString());
}
}
}
for statements are never happening since Item.checked and CheckedItems count is always Zero.
Any help would be greatly appreciated.
Thks in advance.