Last post Apr 08, 2012 01:07 AM by deusbelli
Apr 05, 2012 03:24 AM|deusbelli|LINK
How can I localize data returned from the database? For example, I have a data-bound label for CompensationType. If it returns the value "2" how can I localize that "2"? I already have the resource files setup and ready.
All the examples that I have seen localize static data, I can't find anything that localizes data returned from the database.
BTW - I know how to dynamically create a drop-down list and bind the selected value, that works just fine. I just need to figure out what to do with the label...
Apr 07, 2012 01:54 PM|mm10|LINK
int val = 2;
Label1.Text = val.ToString("N", new CultureInfo("fr-FR")));
Apr 08, 2012 01:07 AM|deusbelli|LINK
Thanks for the reply mm10. In case anyone else has a similar problem, the following is the solution I decided on. I am using DNN so some of the code below may seem a little weird.
On the DataBound event of the DetailsView, localize the data in the label control.
Private Sub LocalizeCompTypeDataLabel()
Dim lblCompensationTypeData As Label = CType(dvwOffer.FindControl("lblCompensationTypeData"), Label)
If Not IsNothing(lblCompensationTypeData) Then
'Use the CompType resource file
Dim strResourceFilePath As String = Me.TemplateSourceDirectory & "/" & Services.Localization.Localization.LocalResourceDirectory & "/CompType.ascx"
lblCompensationTypeData.Text = Localization.GetString(lblCompensationTypeData.Text, strResourceFilePath)
Catch exc As Exception 'Module failed to load
Some sample data from the RESX file: