Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1810
How to set webdatagrid to use culture info
posted

Hi, I can´t get the WebDataGrid displaying numeric data with format.

<ig:WebDataGrid ID="grdResultados" runat="server" Width="100%" AutoGenerateColumns="False">
	<Behaviors>
        	<ig:Paging Enabled="true" PageSize="20" PagerMode="NumericFirstLast" PagerAppearance="Top" FirstPageText="Primera" QuickPages="3">
                </ig:Paging>
                <ig:Filtering>
                </ig:Filtering>
	</Behaviors>
</ig:WebDataGrid>

Code behind:

    private void GetResults()
    {
        //Culture info del cliente
        if (Request.UserLanguages.Count() > 0)
            System.Threading.Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(Request.UserLanguages[0]);

        DataSet ds = mServer.ExecuteQuery(q);
        Session["resultSet"] = ds.Tables[0];
        for (int i = 0; i < ds.Tables[0].Columns.Count; i++)
        {
                var lField = new BoundDataField();
                lField.DataType = "System.Single";
                lField.DataFormatString = "{0:N}";
                lField.DataFieldName = ds.Tables[0].Columns[i].ColumnName;
                lField.Key = ds.Tables[0].Columns[i].ColumnName;
                lField.Header.Text = ds.Tables[1].Rows[i].ItemArray[0].ToString();
                grdResultados.Columns.Add(lField);
        }
        grdResultados.DataSource = ds.Tables[0];
        grdResultados.DataBind();
        grdResultados.Behaviors.Paging.PageIndex = 0;
        grdResultados.Behaviors.Paging.LastPageText = "Última(" + grdResultados.Behaviors.Paging.PageCount.ToString() + ")";
        upResultados.Update();
    }

But the grid shows like this:

Even when the culture Info is spanish.

Any clue?

Thanks in advance, regards