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

Localization for radgrid

10 Answers 233 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Mugdha Aditya
Top achievements
Rank 1
Mugdha Aditya asked on 02 Aug 2011, 12:52 PM
I have dynamically created grid in my application in which one column is numaric one.

i want to change its formate accordinging to localization of machine.

eg. English US (en-US) locazlizaton on our machine , if want to write  100 number in US localization then we will write it as
1,00.00
if its Argentina Spanish (es-AR) localization then 1.00,00

like wise.

i want o use localization for that specific column. how to do that?



10 Answers, 1 is accepted

Sort by
0
Mugdha Aditya
Top achievements
Rank 1
answered on 02 Aug 2011, 07:28 PM
Thanks for the reply jayesh :)
but 2nd link is not useful bcz m creating runtime columns n binding datable to grid. :(

in 1st link they have added culture for whole grid :(
0
Accepted
Tsvetina
Telerik team
answered on 08 Aug 2011, 08:26 AM
Hi Mugdha,

You could try wiring the ItemDataBound event of RadGrid and use the same conversion method for the cell text as the one shown in the second link.
protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e)
{
    if (e.Item is GridDataItem)
    {
        int val = Convert.ToInt32((e.Item as GridDataItem)["ColUniqueName"].Text);
        (e.Item as GridDataItem)["ColUniqueName"].Text = ConvertValue(val);
    }
}
protected string ConvertValue(object val)
{
    return ((int)val).ToString("C", CultureInfo.CreateSpecificCulture("en-US"));
}


All the best,
Tsvetina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Mugdha Aditya
Top achievements
Rank 1
answered on 14 Sep 2011, 07:06 AM
Hey.... Thanuku so much...
it works perfect.

i want another help .. :)

You have added localization hardcoded , if i want to get machine localization then what to do?

i have done below , is that correct.. any idea ?

protected string ConvertValue(object val)
{
    return ((int)val).ToString("C", CultureInfo.CreateSpecificCulture(System.Threading.Thread.CurrentThread.CurrentUICulture.Name));
}



 

 

 

 

0
Mugdha Aditya
Top achievements
Rank 1
answered on 12 Oct 2011, 07:11 AM
Any updates :(

Actully am tring but i didnt not find any solution up till now.
it will be helpfull if you guys help me for this.
0
Tsvetina
Telerik team
answered on 13 Oct 2011, 01:57 PM
Hi Mugdha,

Your approach is correct, I tested it on my side too and it works fine. What problems do you encounter with using it?

Regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Mugdha Aditya
Top achievements
Rank 1
answered on 24 Oct 2011, 02:28 PM
hi..

i have change my machine culture to spanish(argentina) i.e. es-AR in ("Regional and Language Options" control panel.)
i have tried below code to get machine localization but it always gives culture as en-US.


string strCulture = System.Globalization.CultureInfo.CurrentCulture;

 

0
Tsvetina
Telerik team
answered on 27 Oct 2011, 03:40 PM
Hi Mugdha,

You can try the following:
protected void Page_PreRender(object sender, EventArgs e)
{
    Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);
    string strCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
    Response.Write(strCulture);
}



Kind regards,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
0
Mugdha Aditya
Top achievements
Rank 1
answered on 04 Nov 2011, 07:59 AM
Thanks for your reply.. But its not working.
Request.UserLanguages[0] it return me en-US
Request.UserLanguages[1] returns me selected language (es-AR).


I have done below changes in my regonal settings. -> Regional options - >
Selected language as spanish (argentina)

then in adanced tab Selected language as spanish (argentina) and clicked on Apply all settings to the current user account and to the default user profile then apply and ok.
then restared my pc.

Am i missing somthing in settings??


0
Tsvetina
Telerik team
answered on 08 Nov 2011, 02:27 PM
Hi Mugdha,

I am not sure what you are doing wrong but if your user's browser uses a certain culture, it should be detected through the user languages.
If you still have problems with this, try addressing common ASP.NET resources since the issue at hand is not directly related to our controls.
http://forums.asp.net/t/1708695.aspx/1
http://forums.asp.net/t/1551331.aspx/1

All the best,
Tsvetina
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now
Tags
Grid
Asked by
Mugdha Aditya
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Mugdha Aditya
Top achievements
Rank 1
Tsvetina
Telerik team
Share this question
or