This is a migrated thread and some comments may be shown as answers.

format date doesn't work

2 Answers 146 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DANA
Top achievements
Rank 1
Veteran
DANA asked on 01 Feb 2012, 08:49 AM
hi,

I have a grid that gets it's data from oracle table, using stored procedures.

protected function fixdate(byref dt as datatable) as datatable
for each myrow in dt.rows
  try
    myrow("send_date") = cdate(myow("send_date")).tostring("dd/MM/yyyy")
catch ex as exception
...
end try
next
return dt

when I debug - everything works fine, but when I open the grid in my server application (at run time)  - the date change format to "mm/dd/yyyy"


that's the grid code:

<telerik:RadGrid Skin="innovation" EnableEmbeddedSkins="false" ID="RadGrid1" 
              dir="rtl" HeaderStyle-ForeColor="White" AllowFilteringByColumn="True"  
    AllowSorting="True" AllowPaging="True"  BorderColor="#74ABAE" BackColor="White"
    BorderWidth="2px" runat="server" HeaderStyle-Font-Size="Small"  ItemStyle-Font-Size="Small"
    AlternatingItemStyle-Font-Size="Small" ItemStyle-BackColor="White" ItemStyle-ForeColor="Black"
     PageSize="7" AutoGenerateColumns="False" PagerStyle-Font-Size="Small" 
     AlternatingItemStyle-ForeColor="Black"
   Culture="Hebrew" GridLines="Vertical" Width="666px" 
      style="margin-right: 30px"
    <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Black"
    </HeaderContextMenu
        <ItemStyle BackColor="White" Font-Size="Small" ForeColor="Black" /> 
    <PagerStyle mode="NumericPages" ShowPagerText="false"></PagerStyle
    <MasterTableView
    <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings
           <Columns
                 <telerik:GridBoundColumn CurrentFilterFunction="Contains"
                     DataField="IDEA_CODE" UniqueName="IDEA_CODE" HeaderText="ideanum"
                      AutoPostBackOnFilter="true" DataType="System.Int32">  
                    </telerik:GridBoundColumn
                   <telerik:GridBoundColumn UniqueName="LINK" DataField="LINK" HeaderText="" 
                    DataType="System.String" Display="false">  
                    </telerik:GridBoundColumn
                 <telerik:GridBoundColumn DataField="ROWNUM" HeaderText="#" Visible="false"
                 AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.Int32"
                </telerik:GridBoundColumn
                <telerik:GridBoundColumn DataField="SENDER_ID" HeaderText="id"
                UniqueName="SENDER_ID" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.String"
                </telerik:GridBoundColumn
                <telerik:GridBoundColumn DataField="FULLNAME" HeaderText="namef"
                AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.String"
                </telerik:GridBoundColumn
                <telerik:GridBoundColumn DataField="SUBJECT" HeaderText="sub"
                AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.String"
                </telerik:GridBoundColumn
                 <telerik:GridBoundColumn DataField="DESCRIPTION" HeaderText="status"
                 AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.String"
                </telerik:GridBoundColumn
                <telerik:GridBoundColumn DataField="SEND_DATE" HeaderText="sdate"
                AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                    DataType="System.DateTime" DataFormatString="{0:dd/MM/yy}"
                </telerik:GridBoundColumn>                  
                  <telerik:GridImageColumn HeaderText="comments" UniqueName="FBIMG"
                </telerik:GridImageColumn>     
           
     </Columns
........

can you tell me what causing that problem?

kind regards, Dana

 

 

2 Answers, 1 is accepted

Sort by
0
Accepted
RvdGrint
Top achievements
Rank 1
answered on 01 Feb 2012, 09:15 AM
Dana,

This is caused by the Culture settings that are used.
the Telerik controls adapt the culture settings form the browser. You can set the culture settings for the controls, you did it with specifing 'Hebrew' as Culture. Although I believe Hebrew is not a valid culture, her is a list of valid cultures: http://sharpertutorials.com/list-of-culture-codes/
You can set the Culture for you're application in an override of the page InitializeCulture:
protected override void InitializeCulture()
{
  if (Request.IsAuthenticated)
  {
    string sCulture = "he-IL";
 
    UICulture = sCulture;
    Culture = sCulture;
 
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(sCulture);
    Thread.CurrentThread.CurrentUICulture = new CultureInfo(sCulture);
  }
 
  base.InitializeCulture();
}

In this case the telerik controls will adapt this Culture setting and specifing the culture for every control is not necessary anymore.

Regards,
  Jos
0
DANA
Top achievements
Rank 1
Veteran
answered on 01 Feb 2012, 10:38 AM
great, it's working perfect now!
Tags
Grid
Asked by
DANA
Top achievements
Rank 1
Veteran
Answers by
RvdGrint
Top achievements
Rank 1
DANA
Top achievements
Rank 1
Veteran
Share this question
or