I'm looking for a way to control the culture of the edit form that is created by a radgrid's edit button
I've got a radgrid connected to a simple objectdatasource.
There are two date values in the object.
This is my page load:
protected void Page_Load(object sender, EventArgs e)
{
RadGrid1.Culture = new CultureInfo("en-GB");
//RadGrid1.Rebind();
}
I've set DataFormatString="{0:dd/MM/yyyy}" on the date gridboundcolumns
Now the problem is, the dates are in en-GB in the grid, but when clicking edit, the format is assumed to be en-US
basically I can have a date of 2/11/2011 (November 2, 2011) in the grid, click edit and see 2/11/2011 in the edit box, click update, and the radgrid now displays 11/2/2011 (February 11, 2011), if I click edit again and update, the radgrid will display 2/11/2011
Now, this time when I click edit, if I enter 2 November 2011, then the date is passed correctly, in en-GB. This makes me think that this edit form is assuming en-US, even though the grid (and the thread culture) is en-GB.
Adding the RadGrid1.Rebind(); to the page load seems to fix the problem, but then multple edit buttons start appearing
8 Answers, 1 is accepted

you can also set culture to datepicker On insert/Edit mode.
<
telerik:GridDateTimeColumn
DataField
=
"myData"
UniqueName
=
"myData"
HeaderText
=
"myData"
PickerType
=
"DatePicker"
></
telerik:GridDateTimeColumn
>
void
RadGrid2_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem item = e.Item
as
GridEditableItem;
RadDatePicker dp = item[
"myData"
].Controls[0]
as
RadDatePicker;
dp.Culture =
"Set your culture here"
;
}
}
Thanks,
Jayesh Goyani


Cheers,
Roger
Since the columns are part of the grid, in order to change the Culture you will have to set it directly to the grid, not to a particular column. Since changing the culture to one column only is not expected to be a common practice, that is the reason why there is no exposed property for the date/time pickers's culture in the column.
Nevertheless, you could always use the approach suggested by Jayesh, where you set the Culture property directly to the date/time picker control or use a GridTemplateColumn instead.
Kind Regards,
Konstantin Dikov
Telerik
Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

<telerik:GridDateTimeColumn UniqueName="std" DataField="StartDate" HeaderText="Nothing"></telerik:GridDateTimeColumn>I want to bind the date in ar-SA culture(aurab) when im when im adding the GridDateTimeColumn it is getting error page. thanks in advance.
Please share the error that you are receiving and provide some additional information about the data type of your "StartDate" field.
Looking forward to your reply.
Regards,
Konstantin Dikov
Telerik
See What's Next in App Development. Register for TelerikNEXT.

Hi Konstantin
Dikov,
<telerik:RadGrid runat="server" AllowFilteringByColumn="true" ID="RadGrid1"
AutoGenerateColumns="false" OnNeedDataSource="RadGrid1_NeedDataSource"
OnItemDataBound="RadGrid1_ItemDataBound">
<MasterTableView>
<Columns>
<telerik:GridBoundColumn DataField="OrgFeeScheduleID"
HeaderText="ID">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="Name"
HeaderText="Item">
</telerik:GridBoundColumn>
<telerik:GridDateTimeColumn
UniqueName="std"
DataField="StartDate"
HeaderText="StartDate"></telerik:GridDateTimeColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
This is my grid I want to display the data based on the
culture (ar-SA) when im running the page
It is getting error page because of GridDateTimeColumn
Error Message:
Valid values are between
1318 and 1500, inclusive.
Parameter name: year
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.ArgumentOutOfRangeException: Valid values are between 1318
and 1500, inclusive.
Parameter name: year
I try to apply DateTimeFormat as GregorianCalendar but i field
Thanks&Regard's
Siva
In order to change the calendar to Gregorian calendar correctly in this particular scenario, you will have to override the InitializeCulture method on the page as shown below:
protected
override
void
InitializeCulture()
{
culture =
new
System.Globalization.CultureInfo(
"ar-SA"
);
culture.DateTimeFormat.Calendar =
new
GregorianCalendar();
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
base
.InitializeCulture();
}
Hope this helps.
Regards,
Konstantin Dikov
Telerik
See What's Next in App Development. Register for TelerikNEXT.