Problem with setting WebGrid's Culture

5 replies. Last post: January 13, 2011 9:16 PM by Handy Surya
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
Shawn AugustMember

Where should the WebGrid's Culture should be set? In the following thread (http://www.intersoftpt.com/Community/WebGrid/Problem-with-Culture-and-Text-Settings/), the logic to set the WebGrid's culture is set within the page's PreRender event.  This doesn't work for me. However, if I set the culture within the WebGrid's OnInitializeLayout event, it seems to work but has some issues.

For example, the en-GB format works properly only if I use the following format: "DD-MM-YYYY" such as 01-10-11 which is displayed as 01-Oct-2011 where as the following format ("DD/MM/YYYY" such as 01/10/11 displays incorrect as 10-Jan-2011. Why?

/// <summary>
        /// Handles the Treaty Claim's DataGrid control's OnInitializeLayout event
        /// </summary>
        /// <param name="sender">Sender</param>
        /// <param name="e">Event arguments</param>
        protected void grdTreatyClaims_OnInitializeLayout(object sender, ISNet.WebUI.WebGrid.LayoutEventArgs e)
        {
            // Set the user's culture
            this.SetUserCulture();
        }

        /// <summary>
        /// Set the user's culture
        /// </summary>
        private void SetUserCulture()
        {
            Common.Utility.TraceLogger.Instance.Write("SetUserCulture [START]");

            if (this.Security != null && this.Security.UserProfile != null)
            {
                // Get/Set culture's format
                //this.Security.UserProfile.Culture
                CultureInfo culture = new CultureInfo("en-GB");
                this.grdTreatyClaims.LayoutSettings.Culture = culture;
                this.grdTreatyClaims.LayoutSettings.TextSettings.UseLanguage = culture.ToString();
            }

            Common.Utility.TraceLogger.Instance.Write("SetUserCulture [END]");
        }

 Markup

<CommonCtrl:EnduranceWebGrid runat="server" ID="grdTreatyClaims" DefaultStyleMode="Elegant"
                Height="100%" Width="100%" UseDefaultStyle="True" EnableViewState="false" ViewStateStorage="None"
                OnInitializeDataSource="grdTreatyClaims_OnInitializeDataSource" OnInitializeLayout="grdTreatyClaims_OnInitializeLayout"
                OnInitializePostBack="grdTreatyClaims_OnInitializePostBack" OnPrepareDataBinding="grdTreatyClaims_OnPrepareDataBinding"
                OnExport="grdTreatyClaims_OnExport" OnBatchUpdate="grdTreatyClaims_OnBatchUpdate"
                OnInitializeRow="grdTreatyClaims_OnInitializeRow">
                <LayoutSettings AllowBatchUpdate="true" BatchUpdateSettings-PromptUnsavedChanges="false" NewRowLostFocusAction="AlwaysUpdate"
                    AllowAddNew="Yes" AllowEdit="Yes" AllowDelete="Yes" EditOnClick="True" AutoHeight="false" RowHeightDefault="22px"
                    AutoWidth="false" AllowColumnFreezing="Yes" AllowExport="No" AllowFilter="No"
                    AllowSelectColumns="Yes" AllowSorting="No" AlwaysShowHelpButton="False" ApplyFiltersKey="Enter"
                    CellPaddingDefault="0" FilterBarVisible="True" HideColumnsWhenGrouped="Default"
                    InProgressUIBehavior="ChangeCursorToHourGlass"
                    PagingExportMode="ExportAllData" PagingMode="VirtualLoad" ResetNewRowValuesOnError="False"
                    ShowFilterStatus="True" VerboseEditingInformation="False" VirtualPageSize="200">
                    <ClientSideEvents OnInitialize="grdTreatyClaims_OnInitialize" OnRowContextMenu="grdTreatyClaims_OnRowContextMenu"
                        OnCheckBoxClick="grdTreatyClaims_OnCheckBoxClick" 
                        OnExitEditMode="grdTreatyClaims_OnExitEditMode"
                        OnAfterExitEditMode="grdTreatyClaims_OnAfterExitEditMode" 
                        OnRowValidate="grdTreatyClaims_OnRowValidate" />
                    <FrameStyle>
                        <BorderSettings>
                            <Top Style="none" />
                            <Bottom Style="none" />
                            <Left Color="#6593cf" Style="solid" Width="1" />
                            <Right Color="#6593cf" Style="solid" Width="1" />
                        </BorderSettings>
                    </FrameStyle>
                    <HeaderStyle CssClass="WebGridHeaderStyle" />
                    <StatusBarStyle CssClass="WebGridStatusBarStyle" />
                    <StatusBarCommandStyle Active-CssClass="WebGridStatusBarCommandStyleActive" Normal-CssClass="WebGridStatusBarCommandStyleNormal"
                        Over-CssClass="WebGridStatusBarCommandStyleOver">
                        <Normal CssClass="WebGridStatusBarCommandStyleNormal" />
                        <Over CssClass="WebGridStatusBarCommandStyleOver" />
                        <Active CssClass="WebGridStatusBarCommandStyleActive" />
                    </StatusBarCommandStyle>
                    <FilterRowStyle CssClass="WebGridFilterRowStyle" />
                    <PreviewRowStyle CssClass="WebGridRowStyle" />
                    <RowStyle CssClass="WebGridRowStyle" />
                    <QuickFilterBarStyle CssClass="WebGridRowStyle" />
                    <RowHeaderStyle CssClass="WebGridRowHeaderStyle" />
                    <SelectedRowStyle CssClass="WebGridSelectedRowStyle" />
                    <EditFocusCellStyle CssClass="WebGridRowStyle" />
                    <FocusCellStyle CssClass="WebGridRowStyle" />
                    <LostFocusRowStyle CssClass="WebGridRowStyle" />
                    <NewRowStyle CssClass="WebGridRowStyle" />
                    <SortedColumnStyle CssClass="WebGridSortedColumnStyle" />
                    <AlternatingRowStyle CssClass="WebGridAlternatingRowStyle" />
                    <EditTextboxStyle CssClass="WebGridEditTextboxStyle" />
                    <FreezePaneSettings AbsoluteScrolling="True" ActiveFrozenColumns="3" MaxFrozenColumns="3"
                        ShowInContextMenu="False" ShowSplitterLine="False" SplitterLineColor="ActiveBorder"
                        SplitterLineWidth="1" />
                </LayoutSettings>
                <RootTable Caption="Claims Transaction" DataKeyField="UniqueID" ColumnFooters="Yes">                
                    <Columns>
                        <ISWebGrid:WebGridColumn Caption="UniqueID" Name="UniqueID" DataType="System.Integer"
                                                 ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit" FilterEditType="NoEdit"
                                                 Width="0px" Visible="false">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="ClaimMasterStatusCode2" Name="ClaimMasterStatusCode2" DataMember="ClaimMasterStatusCode2" 
                                                 DataType="System.String" ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit" FilterEditType="NoEdit"
                                                 Width="0px">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="InceptionDate" Name="InceptionDate" DataMember="InceptionDate" 
                                                 DataFormatString="dd-MMM-yyyy" DataType="System.String"
                                                 ColumnType="Text" EditType="NoEdit" NewRowEditType="NoEdit" FilterEditType="NoEdit"
                                                 Width="0px">
                        </ISWebGrid:WebGridColumn>
                                                                  
                        <ISWebGrid:WebGridColumn Caption="Claim Number" Name="ClaimMasterReference" DataMember="ClaimMasterReference"
                            DataType="System.String" EditType="NoEdit" FilterEditType="TextBox" Width="100px"
                            FooterText="Total">
                        </ISWebGrid:WebGridColumn>                                
                        <ISWebGrid:WebGridColumn Caption="Description" Name="ClaimTitle" DataMember="ClaimTitle"
                            DataType="System.String" EditType="TextBox" FilterEditType="TextBox" Width="150px">
                        </ISWebGrid:WebGridColumn>                                                               
                        <ISWebGrid:WebGridColumn Caption="Date Qual" Name="DateOfLossQualifier" DataMember="DateOfLossQualifier"
                            DataType="System.Integer" ColumnType="Custom" EditType="DropdownList" NewRowEditType="DropdownList"
                            FilterEditType="DropdownList" Width="75px">
                        </ISWebGrid:WebGridColumn> 
                        <ISWebGrid:WebGridColumn Caption="Date of Loss" Name="ClaimDateOfLossFrom" DataMember="ClaimDateOfLossFrom"
                            DataFormatString="dd-MMM-yyyy" DataType="System.String" ColumnType="Text" EditType="CalendarCombo"
                            NewRowEditType="CalendarCombo" FilterEditType="CalendarCombo" Width="75px">
                        </ISWebGrid:WebGridColumn>                                                                                                                
                        <ISWebGrid:WebGridColumn Caption="Reported Date" Name="ClaimAdvisedDate" DataMember="ClaimAdvisedDate"
                            DataFormatString="dd-MMM-yyyy" DataType="System.String" ColumnType="Text" EditType="CalendarCombo"
                            NewRowEditType="CalendarCombo" FilterEditType="CalendarCombo" Width="90px">
                        </ISWebGrid:WebGridColumn>   
                        <ISWebGrid:WebGridColumn Caption="Event Date" Name="DateOfEvent" DataMember="DateOfEvent"
                            DataFormatString="dd-MMM-yyyy" DataType="System.String" ColumnType="Text" EditType="CalendarCombo"
                            NewRowEditType="CalendarCombo" FilterEditType="CalendarCombo" Width="90px">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Level 1 Cat" Name="ClaimLevel1CATCode" DataMember="ClaimLevel1CATCode"
                            DataType="System.String" ColumnType="Custom" EditType="DropdownList" NewRowEditType="DropdownList"
                            FilterEditType="DropdownList" Width="100px">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Level 3 Cat" Name="ClaimLevel3CATCode" DataMember="ClaimLevel3CATCode"
                            DataType="System.String" ColumnType="Custom" EditType="DropdownList" NewRowEditType="DropdownList"
                            FilterEditType="DropdownList" Width="100px">
                        </ISWebGrid:WebGridColumn>                            
                        <ISWebGrid:WebGridColumn Caption="Cause of Loss" Name="LossAnalysis1Code" DataMember="LossAnalysis1Code"
                            DataType="System.String" ColumnType="Custom" EditType="DropdownList" NewRowEditType="DropdownList"
                            FilterEditType="DropdownList" Width="120px">
                        </ISWebGrid:WebGridColumn>
                        
                        
                        <ISWebGrid:WebGridColumn Caption="Paid" Name="Paid" DataMember="Paid" DataFormatString="#,##0.00"
                            DataType="System.Decimal" DefaultValue="0" EditType="TextBox" FilterEditType="TextBox" Width="80px"
                            AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Expenses" Name="Expenses" DataMember="Expenses" DataFormatString="#,##0.00" 
                            DataType="System.Decimal" DefaultValue="0" EditType="TextBox" FilterEditType="TextBox"
                            Width="80px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Salvage" Name="Salvage" DataMember="Salvage" DataFormatString="#,##0.00"
                            DataType="System.Decimal" DefaultValue="0" EditType="TextBox" FilterEditType="TextBox" Width="80px"
                            AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Cash Loss" Name="CashLoss" DataMember="CashLoss" DataFormatString="#,##0.00"
                            DataType="System.Decimal" DefaultValue="0" EditType="TextBox" FilterEditType="TextBox"
                            Width="80px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Refund" Name="Refund" DataMember="Refund" DataFormatString="#,##0.00"
                            DataType="System.Decimal" DefaultValue="0" EditType="TextBox" FilterEditType="TextBox" Width="80px"
                            AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Port In" Name="ClaimPortfolioIn" DataMember="ClaimPortfolioIn"
                            DataFormatString="#,##0.00" DefaultValue="0" DataType="System.Decimal" EditType="TextBox" FilterEditType="TextBox"
                            Width="80px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Port Out" Name="ClaimPortfolioOut" DataMember="ClaimPortfolioOut"
                            DataFormatString="#,##0.00" DefaultValue="0" DataType="System.Decimal" EditType="TextBox" FilterEditType="TextBox"
                            Width="80px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        
                        
                        <ISWebGrid:WebGridColumn Caption="Current Ind O/S" Name="CurrentINDOutstanding" DataMember="CurrentINDOutstanding"
                            DataFormatString="#,##0.00" DataType="System.Decimal" DefaultValue="0" EditType="NoEdit" FilterEditType="TextBox"
                            Width="90px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption=" " Name="IncludeINDOutstanding" DataMember="IncludeINDOutstanding"
                            ColumnType="CheckBox" EditType="Checkbox" FilterEditType="NoEdit" Width="25px">
                        </ISWebGrid:WebGridColumn>                          
                        <ISWebGrid:WebGridColumn Caption="New Ind O/S" Name="INDOutstanding" DataMember="INDOutstanding"
                            DataFormatString="#,##0.00" DataType="System.Decimal" DefaultValue="0" EditType="TextBox" FilterEditType="TextBox"
                            Width="90px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        
                        <ISWebGrid:WebGridColumn Caption="Current Fee O/S" Name="CurrentFEEOutstanding" DataMember="CurrentFEEOutstanding"
                            DataFormatString="#,##0.00" DataType="System.Decimal" DefaultValue="0" EditType="NoEdit" FilterEditType="TextBox"
                            Width="90px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption=" " Name="IncludeFEEOutstanding" DataMember="IncludeFEEOutstanding"
                            ColumnType="CheckBox" EditType="Checkbox" FilterEditType="NoEdit" Width="25px">
                        </ISWebGrid:WebGridColumn>                          
                        <ISWebGrid:WebGridColumn Caption="New Fee O/S" Name="FEEOutstanding" DataMember="FEEOutstanding"
                            DataFormatString="#,##0.00" DataType="System.Decimal" DefaultValue="0" EditType="TextBox" FilterEditType="TextBox"
                            Width="90px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                                                                                
                        <ISWebGrid:WebGridColumn Caption="Current ACR O/S" Name="CurrentACROutstanding" DataMember="CurrentACROutstanding"
                            DataFormatString="#,##0.00" DataType="System.Decimal" DefaultValue="0" EditType="NoEdit" FilterEditType="TextBox"
                            Width="90px" AggregateFunction="Sum">                              
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption=" " Name="IncludeACROutstanding" DataMember="IncludeACROutstanding"
                            ColumnType="CheckBox" EditType="Checkbox" FilterEditType="NoEdit" Width="25px">
                        </ISWebGrid:WebGridColumn>                          
                        <ISWebGrid:WebGridColumn Caption="New ACR O/S" Name="ACROutstanding" DataMember="ACROutstanding"
                            DataFormatString="#,##0.00" DataType="System.Decimal" DefaultValue="0" EditType="TextBox" FilterEditType="TextBox"
                            Width="90px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>
                        
                        <ISWebGrid:WebGridColumn Caption="Current ACE O/S" Name="CurrentACEOutstanding" DataMember="CurrentACEOutstanding"
                            DataFormatString="#,##0.00" DataType="System.Decimal" DefaultValue="0" EditType="NoEdit" FilterEditType="TextBox"
                            Width="90px" AggregateFunction="Sum">                              
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption=" " Name="IncludeACEOutstanding" DataMember="IncludeACEOutstanding"
                            ColumnType="CheckBox" EditType="Checkbox" FilterEditType="NoEdit" Width="25px">
                        </ISWebGrid:WebGridColumn>                          
                        <ISWebGrid:WebGridColumn Caption="New ACE O/S" Name="ACEOutstanding" DataMember="ACEOutstanding"
                            DataFormatString="#,##0.00" DataType="System.Decimal" DefaultValue="0" EditType="TextBox" FilterEditType="TextBox"
                            Width="90px" AggregateFunction="Sum">
                        </ISWebGrid:WebGridColumn>                       
  
  
                        <ISWebGrid:WebGridColumn Caption="Current IND" Name="CurrentIND" DataMember="CurrentIND" DefaultValue="0"
                            DataFormatString="#,##0.00" DataType="System.Decimal" EditType="NoEdit" FilterEditType="NoEdit"
                            AggregateFunction="Sum" Visible="false">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Current FEE" Name="CurrentFEE" DataMember="CurrentFEE" DefaultValue="0"
                            DataFormatString="#,##0.00" DataType="System.Decimal" EditType="NoEdit" FilterEditType="NoEdit"
                            AggregateFunction="Sum" Visible="false">                            
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Current REC" Name="CurrentREC" DataMember="CurrentREC" DefaultValue="0"
                            DataFormatString="#,##0.00" DataType="System.Decimal" EditType="NoEdit" FilterEditType="NoEdit"
                            AggregateFunction="Sum" Visible="false">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Current Incurred" Name="CurrentIncurred" DataMember="CurrentIncurred" DefaultValue="0"
                            DataFormatString="#,##0.00" DataType="System.Decimal" EditType="NoEdit" FilterEditType="NoEdit"
                            AggregateFunction="Sum" Visible="false">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Incurred" Name="Incurred" DataMember="" DefaultValue="0"
                            DataFormatString="#,##0.00" DataType="System.Decimal" EditType="TextBox" FilterEditType="NoEdit" 
                            AggregateFunction="Sum" Visible="false">
                        </ISWebGrid:WebGridColumn>
                        <ISWebGrid:WebGridColumn Caption="Movement" Name="IncurredMovement" DataMember="" DefaultValue="0"
                            DataFormatString="#,##0.00" DataType="System.Decimal" EditType="TextBox" FilterEditType="NoEdit"
                            AggregateFunction="Sum" Visible="false">
                        </ISWebGrid:WebGridColumn>
                    </Columns>
                </RootTable>
            </CommonCtrl:EnduranceWebGrid>

 

 

All times are GMT -5. The time now is 12:01 PM.
Previous Next