I have a scenario in which I have a RadGrid with in-place editing enabled. Several of the columns have custom editors referenced by the ColumnEditorID attribute, and all of the column editors in the grid are Telerik controls. I am catching the ItemCommand event in the code-behind to process the grid commands. The AllowMultiRowEdit attribute of the grid is set to false.
If I click Edit on one of the rows, the row goes into Edit mode correctly, and all of the formatting rules for each column editor are respected (e.g. I have a currency column that displays with a dollar sign and two decimal places, an integer column that displays with no decimal places and no commas, and the numeric columns are aligned right). Now, if I click Edit on a different row, the row that was previously in Edit mode exits edit mode and the second row that was clicked goes into Edit mode, again, as expected. However, the column editors in the second row have now lost the formatting rules. The currency column displays with no dollar sign, the integer column displays with decimal places and commas, and the numeric columns are no longer aligned right.
Note that the formatting is only lost on the editors themselves. The cells, when in view mode, retain their appropriate formatting.
Here is my grid:
And here is my code-behind:
Any help would be greatly appreciated.
Thanks!
If I click Edit on one of the rows, the row goes into Edit mode correctly, and all of the formatting rules for each column editor are respected (e.g. I have a currency column that displays with a dollar sign and two decimal places, an integer column that displays with no decimal places and no commas, and the numeric columns are aligned right). Now, if I click Edit on a different row, the row that was previously in Edit mode exits edit mode and the second row that was clicked goes into Edit mode, again, as expected. However, the column editors in the second row have now lost the formatting rules. The currency column displays with no dollar sign, the integer column displays with decimal places and commas, and the numeric columns are no longer aligned right.
Note that the formatting is only lost on the editors themselves. The cells, when in view mode, retain their appropriate formatting.
Here is my grid:
<
telerik:RadGrid
ID
=
"grdChecksIssued"
runat
=
"server"
GridLines
=
"None"
AllowPaging
=
"True"
AllowAutomaticUpdates
=
"true"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"false"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
AllowMultiRowEdit
=
"false"
>
<
headercontextmenu
cssclass
=
"GridContextMenu GridContextMenu_Default"
enableimagesprites
=
"True"
>
</
headercontextmenu
>
<
mastertableview
CommandItemDisplay
=
"Top"
AllowSorting
=
"true"
TableLayout
=
"Fixed"
CommandItemSettings-AddNewRecordText
=
"Add Issued Check"
AllowMultiColumnSorting
=
"false"
EditMode
=
"InPlace"
InsertItemDisplay
=
"Bottom"
AutoGenerateColumns
=
"false"
NoMasterRecordsText
=
"No checks issued today."
>
<
commanditemsettings
ShowRefreshButton
=
"False"
/>
<
Columns
>
<
telerik:GridButtonColumn
CommandName
=
"Delete"
Text
=
"Delete"
UniqueName
=
"DeleteColumn"
>
<
HeaderStyle
Width
=
"50px"
/>
</
telerik:GridButtonColumn
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn1"
UpdateText
=
"Save"
InsertText
=
"Save"
>
<
HeaderStyle
Width
=
"50px"
/>
<
ItemStyle
cssclass
=
"EditColumn"
/>
</
telerik:GridEditCommandColumn
>
<
telerik:GridNumericColumn
DataField
=
"PPIssuedID"
DataType
=
"System.Int64"
HeaderText
=
"PPIssuedID"
SortExpression
=
"PPIssuedID"
UniqueName
=
"PPIssuedID"
Visible
=
"False"
>
</
telerik:GridNumericColumn
>
<
telerik:GridNumericColumn
DataField
=
"UserID"
DataType
=
"System.Int64"
HeaderText
=
"UserID"
SortExpression
=
"UserID"
UniqueName
=
"UserID"
Visible
=
"False"
>
</
telerik:GridNumericColumn
>
<
telerik:GridDropDownColumn
DataField
=
"AcctNo"
DataType
=
"System.Int64"
HeaderText
=
"Account"
SortExpression
=
"AcctNo"
DataSourceID
=
"odsPPAccounts"
UniqueName
=
"AcctNo"
DropDownControlType
=
"RadComboBox"
ListTextField
=
"DisplayNameAcct"
ListValueField
=
"AcctNo"
>
<
HeaderStyle
Width
=
"140px"
/>
<
ItemStyle
CssClass
=
"AcctNoColumn"
/>
</
telerik:GridDropDownColumn
>
<
telerik:GridNumericColumn
DataField
=
"SerialNo"
DataType
=
"System.Int32"
ColumnEditorID
=
"gceSerialNo"
HeaderText
=
"Serial No."
SortExpression
=
"SerialNo"
UniqueName
=
"SerialNo"
>
<
HeaderStyle
HorizontalAlign
=
"Right"
Width
=
"75px"
/>
<
ItemStyle
HorizontalAlign
=
"Right"
cssclass
=
"SerialNoColumn"
/>
</
telerik:GridNumericColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"WriteDate"
HeaderText
=
"Write Date"
SortExpression
=
"WriteDate"
UniqueName
=
"WriteDate"
DataFormatString
=
"{0:MM/dd/yyyy}"
DataType
=
"System.DateTime"
ColumnEditorID
=
"gceWriteDate"
>
<
HeaderStyle
Width
=
"100px"
/>
</
telerik:GridDateTimeColumn
>
<
telerik:GridNumericColumn
DataField
=
"Amount"
HeaderText
=
"Amount"
ShowSortIcon
=
"true"
SortExpression
=
"Amount"
UniqueName
=
"Amount"
DataType
=
"System.Decimal"
NumericType
=
"Currency"
ColumnEditorID
=
"gceAmount"
>
<
HeaderStyle
Width
=
"95px"
HorizontalAlign
=
"Right"
/>
<
ItemStyle
HorizontalAlign
=
"Right"
CssClass
=
"AmountColumn"
/>
</
telerik:GridNumericColumn
>
<
telerik:GridBoundColumn
DataField
=
"Payee"
HeaderText
=
"Payee"
ColumnEditorID
=
"gcePayee"
SortExpression
=
"Payee"
UniqueName
=
"Payee"
AllowSorting
=
"true"
>
<
ItemStyle
CssClass
=
"IssCheckPayee"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"IsVoid"
DataType
=
"System.Boolean"
HeaderText
=
"Void"
SortExpression
=
"IsVoid"
UniqueName
=
"IsVoid"
>
<
HeaderStyle
Width
=
"65px"
/>
</
telerik:GridCheckBoxColumn
>
</
Columns
>
</
mastertableview
>
</
telerik:RadGrid
>
<
telerik:GridNumericColumnEditor
ID
=
"gceSerialNo"
runat
=
"server"
>
<
NumericTextBox
ID
=
"NumericTextBox1"
runat
=
"server"
MaxLength
=
"10"
MinValue
=
"0"
Width
=
"45px"
>
<
NumberFormat
DecimalDigits
=
"0"
GroupSeparator
=
""
DecimalSeparator
=
" "
/>
<
EnabledStyle
HorizontalAlign
=
"Right"
/>
</
NumericTextBox
>
</
telerik:GridNumericColumnEditor
>
<
telerik:GridNumericColumnEditor
ID
=
"gceAmount"
runat
=
"server"
>
<
NumericTextBox
ID
=
"NumericTextBox2"
runat
=
"server"
MinValue
=
"0"
MaxValue
=
"999999999999999.99"
>
<
NumberFormat
DecimalDigits
=
"2"
KeepTrailingZerosOnFocus
=
"true"
PositivePattern
=
"$n"
/>
<
EnabledStyle
HorizontalAlign
=
"Right"
Width
=
"65px"
/>
</
NumericTextBox
>
</
telerik:GridNumericColumnEditor
>
<
telerik:GridDateTimeColumnEditor
ID
=
"gceWriteDate"
runat
=
"server"
>
<
TextBoxStyle
Width
=
"90px"
/>
</
telerik:GridDateTimeColumnEditor
>
<
telerik:GridTextBoxColumnEditor
ID
=
"gcePayee"
runat
=
"server"
>
<
TextBoxStyle
Width
=
"100px"
/>
</
telerik:GridTextBoxColumnEditor
>
<
asp:ObjectDataSource
ID
=
"odsPPAccounts"
runat
=
"server"
DataObjectTypeName
=
"clsDDA"
SelectMethod
=
"GetPPAccounts"
TypeName
=
"WebLinks.PosPayMain"
/>
And here is my code-behind:
Private
Sub
grdChecksIssued_ItemCommand(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
grdChecksIssued.ItemCommand
Select
Case
e.CommandName
Case
RadGrid.InitInsertCommandName
grdChecksIssued.MasterTableView.ClearEditItems()
Case
RadGrid.EditCommandName
grdChecksIssued.MasterTableView.IsItemInserted =
False
Case
RadGrid.PerformInsertCommandName, _
RadGrid.UpdateCommandName
SaveRow(e.Item)
Case
RadGrid.DeleteCommandName
Dim
hshCells
As
New
Hashtable()
CType
(e.Item, GridDataItem).ExtractValues(hshCells)
DeleteRow(hshCells)
End
Select
End
Sub
Private
Sub
grdChecksIssued_NeedDataSource(
ByVal
sender
As
Object
,
ByVal
e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
grdChecksIssued.NeedDataSource
grdChecksIssued.DataSource = GetRows()
End
Sub
Any help would be greatly appreciated.
Thanks!