Ok, I fixed this by setting the culture string in the header of the aspx file:
""Walter Wang [MSFT]"" wrote:
> Hi Devron,
>
> Based on my understanding, your objective here is to set DataFormatString
> of auto-generated columns (DataGrid.AutoGenerateColumns = true) of
> DataGrid. Please feel free to let me know if I've misunderstood anything.
>
> Currently it's not easy to achieve this objective using simple property
> setting, since the auto-generated columns are not added to DataGrid.Columns
> collection and they're not accessible from outside. We have to inherit from
> DataGrid and override CreateColumnSet to get references to the
> auto-generated columns:
>
> namespace myns
> {
> public class MyDataGrid : DataGrid
> {
> protected override System.Collections.ArrayList
> CreateColumnSet(PagedDataSource dataSource, bool useDataSource)
> {
> ArrayList al = base.CreateColumnSet(dataSource, useDataSource);
> foreach (DataGridColumn col in al)
> {
> BoundColumn bc = col as BoundColumn;
> if (bc != null)
> {
> bc.DataFormatString = "{0:dd/MM/yyyy}";
> }
> }
> return al;
> }
> }
>
>
> In your ASPX:
>
> <%@ Register TagPrefix="c" Namespace="myns" Assembly="__code" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> >
> <html xmlns="
http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <c:MyDataGrid ID="grid1" runat="server"></c:MyDataGrid>
>
>
> (Assembly="__code" assumes you're using MyDataGrid from a class file in
> App_Code)
>
>
>
> Also note this is a quick and dirty hack without checking for the column's
> actual data type, you may want to use Reflector
> (
http://www.aisto.com/roeder/dotnet/) to insepect implementation of
> DataGrid.CreateAutoGeneratedColumns to see how to get each column's binding
> data's type.
>
>
> Regards,
> Walter Wang (wawang@online.microsoft.com, remove 'online.')
> Microsoft Online Community Support
>
> ==================================================
> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================
>
> This posting is provided "AS IS" with no warranties, and confers no rights.
>