How to set WebGrid Culture on ClientBinding

7 replies. Last post: September 10, 2012 9:24 PM by Yudi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback

If i try to set Culture to change decimal separator and date format like this

void WebGrid1_InitializeLayout(object sender, LayoutEventArgs e)
        {
            e.Layout.Culture = new System.Globalization.CultureInfo("pl-PL");
        }

It works only with server side binding, I create a sample

first bind to sql table

CREATE TABLE [dbo].[CultureItem](
	[Id] [int] IDENTITY(1,1) NOT NULL,
	[Text] [nvarchar](50) NULL,
	[Date] [datetime] NULL,
	[Numeric] [numeric](11, 2) NULL)

Server Binding

and second web service client binding base on the same data

 public class CultureItem
    {
        public int Id {get;set;}
        public decimal Numeric {get;set;}
        public string Text { get; set; }
        public DateTime Date { get; set; }
    }
 List<CultureItem> r = new List<CultureItem>();
                foreach (DataRow row in s.readTable("CultureItem").Rows)
                {
                    CultureItem it = new CultureItem()
                    {
                        Date = DateTime.Parse(row["Date"].ToString()),
                        Id = int.Parse(row["Id"].ToString()),
                        Numeric = decimal.Parse(row["Numeric"].ToString()),
                          Text= row["Text"].ToString()
                    };                    
                    r.Add(it);
                }

Client Binding

All WebGridSetting is the same but in ClientBindig date format and decimal point don't change no matter what culture I set? How can I do that?

Best regards,

Michal

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