Hi.
I have a GridNumericColumn in a RadGrid that I put a lot of very small numbers in.
If i put 0.01 in edit mode everything is fine. If I put 0.001 in it is changed to 0 when my cursor leaves the box. If I put my cursor back in the box it displays 0.001 again. It saves the value fine but the behaviour will mislead users and is not ideal. How can I stop this happening?
And if I put in values as small as 0.00001, which is quite often, the row won't save at all. I click on update and nothing happens. I know the database field datatype is fine (decimal(18, 12)) because at the moment i have to go and enter the smaller values straight into the database table when the grid won't save. I have to enter values as small 0.000000001.
What can I do to get around this problem?
Thanks for your help. My code is below. It is the "Factor" GridNumericColumn that is giving me the problem...
I have a GridNumericColumn in a RadGrid that I put a lot of very small numbers in.
If i put 0.01 in edit mode everything is fine. If I put 0.001 in it is changed to 0 when my cursor leaves the box. If I put my cursor back in the box it displays 0.001 again. It saves the value fine but the behaviour will mislead users and is not ideal. How can I stop this happening?
And if I put in values as small as 0.00001, which is quite often, the row won't save at all. I click on update and nothing happens. I know the database field datatype is fine (decimal(18, 12)) because at the moment i have to go and enter the smaller values straight into the database table when the grid won't save. I have to enter values as small 0.000000001.
What can I do to get around this problem?
Thanks for your help. My code is below. It is the "Factor" GridNumericColumn that is giving me the problem...
<
form
id
=
"form1"
runat
=
"server"
>
<
div
>
<
telerik:RadScriptManager
ID
=
"RadScriptManager1"
runat
=
"server"
/>
<!-- content start -->
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"RadGrid1"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"RadGrid1"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
ShowStatusBar
=
"True"
DataSourceID
=
"SqlDataSource1"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
AllowSorting
=
"True"
AutoGenerateDeleteColumn
=
"True"
AutoGenerateEditColumn
=
"True"
GridLines
=
"None"
ShowGroupPanel
=
"True"
AllowAutomaticDeletes
=
"true"
AllowAutomaticInserts
=
"true"
AllowAutomaticUpdates
=
"true"
>
<
HeaderContextMenu
EnableImageSprites
=
"True"
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
</
HeaderContextMenu
>
<
MasterTableView
DataSourceID
=
"SqlDataSource1"
AutoGenerateColumns
=
"False"
DataKeyNames
=
"EmissionFactorGroupID"
AllowMultiColumnSorting
=
"True"
PageSize
=
"20"
CommandItemDisplay
=
"Bottom"
CommandItemSettings-AddNewRecordText
=
" Add New Emission Factor Group"
CommandItemSettings-ShowAddNewRecordButton
=
"true"
CommandItemSettings-ShowExportToExcelButton
=
"true"
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"EmissionFactorID"
DataSourceID
=
"SqlDataSource2"
Width
=
"100%"
runat
=
"server"
AutoGenerateColumns
=
"false"
AllowFilteringByColumn
=
"false"
CommandItemDisplay
=
"Bottom"
CommandItemSettings-AddNewRecordText
=
" Add New Emission Factor"
CommandItemSettings-ShowAddNewRecordButton
=
"true"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"EmissionFactorGroupID"
MasterKeyField
=
"EmissionFactorGroupID"
/>
</
ParentTableRelation
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"EmissionGasBreakdownID"
DataSourceID
=
"SqlDataSource3"
Width
=
"100%"
runat
=
"server"
AutoGenerateColumns
=
"false"
AllowFilteringByColumn
=
"false"
CommandItemDisplay
=
"Bottom"
CommandItemSettings-AddNewRecordText
=
" Add New Gas"
CommandItemSettings-ShowAddNewRecordButton
=
"true"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"EmissionFactorID"
MasterKeyField
=
"EmissionFactorID"
/>
</
ParentTableRelation
>
<
Columns
>
<
telerik:GridBoundColumn
Visible
=
"false"
ReadOnly
=
"true"
DataField
=
"EmissionGasBreakdownID"
DataType
=
"System.Int32"
SortExpression
=
"EmissionGasBreakdownID"
UniqueName
=
"EmissionGasBreakdownID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
Visible
=
"false"
ReadOnly
=
"true"
DataField
=
"EmissionFactorID"
SortExpression
=
"EmissionFactorID"
UniqueName
=
"EmissionFactorID"
DataType
=
"System.Int32"
>
</
telerik:GridBoundColumn
>
<
telerik:GridDropDownColumn
DropDownControlType
=
"RadComboBox"
DataType
=
"System.Int32"
DataField
=
"GasID"
HeaderText
=
"Gas"
SortExpression
=
"GasID"
UniqueName
=
"GasID"
DataSourceID
=
"SqlDataSource4"
ListTextField
=
"GasName"
ListValueField
=
"EmissionGasID"
>
</
telerik:GridDropDownColumn
>
<
telerik:GridNumericColumn
DataField
=
"Factor"
DataType
=
"System.Decimal"
HeaderText
=
"Factor"
SortExpression
=
"Factor"
UniqueName
=
"Factor"
KeepNotRoundedValue
=
"true"
>
</
telerik:GridNumericColumn
>
<
telerik:GridBoundColumn
DataField
=
"UOM"
HeaderText
=
"UOM"
SortExpression
=
"UOM"
UniqueName
=
"UOM"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
Visible
=
"false"
ReadOnly
=
"true"
DataField
=
"EmissionFactorID"
DataType
=
"System.Int32"
HeaderText
=
"EmissionFactorID"
SortExpression
=
"EmissionFactorID"
UniqueName
=
"EmissionFactorID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridNumericColumn
DataField
=
"Factor"
DataType
=
"System.Decimal"
HeaderText
=
"Factor"
SortExpression
=
"Factor"
UniqueName
=
"Factor"
KeepNotRoundedValue
=
"true"
AllowRounding
=
"false"
NumericType
=
"Number"
DataFormatString
=
"{0:0.0000000000}"
>
</
telerik:GridNumericColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"EffectiveFrom"
DataType
=
"System.DateTime"
HeaderText
=
"Effective From"
SortExpression
=
"EffectiveFrom"
UniqueName
=
"EffectiveFrom"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridDateTimeColumn
DataField
=
"EffectiveTo"
DataType
=
"System.DateTime"
HeaderText
=
"Effective To"
SortExpression
=
"EffectiveTo"
UniqueName
=
"EffectiveTo"
>
</
telerik:GridDateTimeColumn
>
<
telerik:GridBoundColumn
DataField
=
"Description"
HeaderText
=
"Description"
SortExpression
=
"Description"
UniqueName
=
"Description"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Source"
HeaderText
=
"Source"
SortExpression
=
"Source"
UniqueName
=
"Source"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
Visible
=
"false"
ReadOnly
=
"true"
DataField
=
"EmissionFactorGroupID"
DataType
=
"System.Int32"
HeaderText
=
"EmissionFactorGroupID"
SortExpression
=
"EmissionFactorGroupID"
UniqueName
=
"EmissionFactorGroupID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridNumericColumn
DataField
=
"IPCCTier"
DataType
=
"System.Byte"
HeaderText
=
"IPCC"
SortExpression
=
"IPCCTier"
UniqueName
=
"IPCCTier"
HeaderStyle-Width
=
"20px"
ItemStyle-Width
=
"20px"
NumericType
=
"Number"
>
</
telerik:GridNumericColumn
>
</
Columns
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
ExpandCollapseColumn
Visible
=
"True"
>
</
ExpandCollapseColumn
>
</
telerik:GridTableView
>
</
DetailTables
>
<
CommandItemSettings
ExportToPdfText
=
"Export to Pdf"
></
CommandItemSettings
>
<
RowIndicatorColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
Visible
=
"false"
ReadOnly
=
"true"
DataField
=
"EmissionFactorGroupID"
DataType
=
"System.Int32"
HeaderText
=
"EmissionFactorGroupID"
SortExpression
=
"EmissionFactorGroupID"
UniqueName
=
"EmissionFactorGroupID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"GroupName"
HeaderText
=
"Group Name"
SortExpression
=
"GroupName"
UniqueName
=
"GroupName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ResourceType"
HeaderText
=
"Resource Type"
SortExpression
=
"ResourceType"
UniqueName
=
"ResourceType"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ResourceName"
HeaderText
=
"Name"
SortExpression
=
"ResourceName"
UniqueName
=
"ResourceName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ResourceUOM"
HeaderText
=
"UOM"
SortExpression
=
"ResourceUOM"
UniqueName
=
"ResourceUOM"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"Region"
HeaderText
=
"Region"
SortExpression
=
"Region"
UniqueName
=
"Region"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"OwnerTenantID"
HeaderText
=
"Owner Tenant ID"
SortExpression
=
"OwnerTenantID"
UniqueName
=
"OwnerTenantID"
DataType
=
"System.Int32"
>
</
telerik:GridBoundColumn
>
<
telerik:GridCheckBoxColumn
DataField
=
"Shared"
DataType
=
"System.Boolean"
HeaderText
=
"Shared"
SortExpression
=
"Shared"
UniqueName
=
"Shared"
>
</
telerik:GridCheckBoxColumn
>
</
Columns
>
</
MasterTableView
>
<
ClientSettings
AllowDragToGroup
=
"True"
>
</
ClientSettings
>
</
telerik:RadGrid
>
<
asp:SqlDataSource
ID
=
"SqlDataSource1"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" DeleteCommand="
DELETE FROM [_FFEmissionGasBreakdown] WHERE [EmissionFactorID] IN (SELECT [EmissionFactorID] FROM [_FFEmissionFactor] WHERE ([EmissionFactorGroupID] = @EmissionFactorGroupID));
DELETE FROM [_FFEmissionFactor] WHERE [EmissionFactorGroupID] = @EmissionFactorGroupID;
DELETE FROM [_FFEmissionFactorGroupToGroupSetLink] WHERE [EmissionFactorGroupID] = @EmissionFactorGroupID;
DELETE FROM [_FFEmissionFactorGroup] WHERE [EmissionFactorGroupID] = @EmissionFactorGroupID;
" InsertCommand="
INSERT INTO [_FFEmissionFactorGroup] ([GroupName], [ResourceType], [ResourceName], [ResourceUOM], [Region], [OwnerTenantID], [Shared]) VALUES (@GroupName, @ResourceType, @ResourceName, @ResourceUOM, @Region, @OwnerTenantID, @Shared);
INSERT INTO [_FFEmissionFactorGroupToGroupSetLink] ([EmissionFactorGroupID], [EmissionFactorGroupSetID]) VALUES ((SELECT TOP 1 EmissionFactorGroupID FROM _FFEmissionFactorGroup ORDER BY EmissionFactorGroupID DESC), (SELECT TOP 1 EmissionFactorGroupSetID FROM _FFEmissionFactorGroupSet WHERE GroupSetOwnerTenantID = @OwnerTenantID));
" SelectCommand="SELECT * FROM [_FFEmissionFactorGroup] WHERE ([OwnerTenantID] = @OwnerTenantID) ORDER BY [Region], [GroupName], [ResourceUOM]" UpdateCommand="UPDATE [_FFEmissionFactorGroup] SET [GroupName] = @GroupName, [ResourceType] = @ResourceType, [ResourceName] = @ResourceName, [ResourceUOM] = @ResourceUOM, [Region] = @Region, [OwnerTenantID] = @OwnerTenantID, [Shared] = @Shared WHERE [EmissionFactorGroupID] = @EmissionFactorGroupID">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"OwnerTenantID"
SessionField
=
"OwnerTenantID"
Type
=
"Int32"
/>
</
SelectParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"EmissionFactorGroupID"
Type
=
"Int32"
/>
</
DeleteParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"GroupName"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"ResourceType"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"ResourceName"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"ResourceUOM"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Region"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"OwnerTenantID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Shared"
Type
=
"Boolean"
/>
<
asp:Parameter
Name
=
"EmissionFactorGroupID"
Type
=
"Int32"
/>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"GroupName"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"ResourceType"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"ResourceName"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"ResourceUOM"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Region"
Type
=
"String"
/>
<
asp:SessionParameter
Name
=
"OwnerTenantID"
SessionField
=
"OwnerTenantID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Shared"
Type
=
"Boolean"
/>
</
InsertParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource2"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" SelectCommand="SELECT [EmissionFactorID], [Factor], [EffectiveFrom], [EffectiveTo], [Description], [Source], [EmissionFactorGroupID], [IPCCTier] FROM [_FFEmissionFactor] WHERE ([EmissionFactorGroupID] = @EmissionFactorGroupID) ORDER BY [EffectiveFrom], [Description]" DeleteCommand="DELETE FROM [_FFEmissionGasBreakdown] WHERE [EmissionFactorID] = @EmissionFactorID; DELETE FROM [_FFEmissionFactor] WHERE [EmissionFactorID] = @EmissionFactorID" InsertCommand="INSERT INTO [_FFEmissionFactor] ([Factor], [EffectiveFrom], [EffectiveTo], [Description], [Source], [EmissionFactorGroupID], [IPCCTier], [MaterialID]) VALUES (@Factor, @EffectiveFrom, @EffectiveTo, @Description, @Source, @EmissionFactorGroupID, @IPCCTier, 1)"
UpdateCommand="UPDATE [_FFEmissionFactor] SET [Factor] = @Factor, [EffectiveFrom] = @EffectiveFrom, [EffectiveTo] = @EffectiveTo, [Description] = @Description, [Source] = @Source, [IPCCTier] = @IPCCTier WHERE [EmissionFactorID] = @EmissionFactorID">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"EmissionFactorGroupID"
SessionField
=
"EmissionFactorGroupID"
Type
=
"Int32"
/>
</
SelectParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"EmissionFactorID"
Type
=
"Int32"
/>
</
DeleteParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"Factor"
Type
=
"Decimal"
/>
<
asp:Parameter
Name
=
"EffectiveFrom"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"EffectiveTo"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"Description"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Source"
Type
=
"String"
/>
<
asp:SessionParameter
Name
=
"EmissionFactorGroupID"
SessionField
=
"EmissionFactorGroupID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"IPCCTier"
Type
=
"Byte"
/>
<
asp:Parameter
Name
=
"EmissionFactorID"
Type
=
"Int32"
/>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"Factor"
Type
=
"Decimal"
/>
<
asp:Parameter
Name
=
"EffectiveFrom"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"EffectiveTo"
Type
=
"DateTime"
/>
<
asp:Parameter
Name
=
"Description"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"Source"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"EmissionFactorGroupID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"IPCCTier"
Type
=
"Byte"
/>
</
InsertParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource3"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" DeleteCommand="DELETE FROM [_FFEmissionGasBreakdown] WHERE [EmissionGasBreakdownID] = @EmissionGasBreakdownID" InsertCommand="INSERT INTO [_FFEmissionGasBreakdown] ([EmissionFactorID], [GasID], [Factor], [UOM]) VALUES (@EmissionFactorID, @GasID, @Factor, @UOM)" SelectCommand="SELECT * FROM [_FFEmissionGasBreakdown] WHERE EmissionFactorID = @EmissionFactorID ORDER BY [GasID]" UpdateCommand="UPDATE [_FFEmissionGasBreakdown] SET [GasID] = @GasID, [Factor] = @Factor, [UOM] = @UOM WHERE [EmissionGasBreakdownID] = @EmissionGasBreakdownID">
<
SelectParameters
>
<
asp:SessionParameter
Name
=
"EmissionFactorID"
SessionField
=
"EmissionFactorID"
Type
=
"String"
/>
</
SelectParameters
>
<
DeleteParameters
>
<
asp:Parameter
Name
=
"EmissionGasBreakdownID"
Type
=
"Int32"
/>
</
DeleteParameters
>
<
UpdateParameters
>
<
asp:Parameter
Name
=
"GasID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Factor"
Type
=
"Decimal"
/>
<
asp:Parameter
Name
=
"UOM"
Type
=
"String"
/>
<
asp:Parameter
Name
=
"EmissionGasBreakdownID"
Type
=
"Int32"
/>
</
UpdateParameters
>
<
InsertParameters
>
<
asp:Parameter
Name
=
"EmissionFactorID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"GasID"
Type
=
"Int32"
/>
<
asp:Parameter
Name
=
"Factor"
Type
=
"Decimal"
/>
<
asp:Parameter
Name
=
"UOM"
Type
=
"String"
/>
</
InsertParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SqlDataSource4"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:SiteSqlServer %>" SelectCommand="SELECT EmissionGasID, GasName FROM _FFEmissionGas Order By GasName" />
</
div
>
</
form
>