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

Pager Text Not changing on localization

3 Answers 45 Views
Grid
This is a migrated thread and some comments may be shown as answers.
fred williams
Top achievements
Rank 1
fred williams asked on 14 Jul 2016, 03:17 PM

So I have a grid inside an asp update panel. I have a dropdown list with differnet cultutres on the master page. In the need data source event handler for the grid, I check the value of the dropdown like so

    Protected Sub grid_NeedDataSource(ByVal sender As Object, ByVal e As GridNeedDataSourceEventArgs) Handles grid.NeedDataSource
        PopulateGrid(False)
        Dim ddl As New DropDownList()
        Dim strLanguage As String
        ddl = CType(Me.Master.FindControl("ddlLanguage"), DropDownList)
        strLanguage = ddl.SelectedValue
        If strLanguage Is Nothing Or strLanguage.Length = 0 Then
            strLanguage = "en-US"
        End If
        Dim newCulture As CultureInfo = CultureInfo.CreateSpecificCulture(strLanguage)
        gridVirtualPoints.Culture = newCulture
    End Sub

Here is the PopulateGrid method called in the first line of the above method

    Private Sub PopulateGrid(ByVal reload As Boolean)
        If CurrentUser.isAdmin Or CurrentUser.isParent Then
            Dim Customers = dal.SelectCustomersByCustomerID(CurrentCustomer.CustomerID)
            Dim CustomerIDs As New List(Of String)

            For Each Customer As Customer In Customers
                If Not Customer Is Nothing Then
                    CustomerIDs.Add(Customer.CustomerID)
                End If
            Next
        //this just gets the data from the database
            grid.DataSource = dal.getgriddata(CustomerIDs)
        Else
            grid.DataSource = dal.getgriddata(CurrentUser.UserID)
        End If

        If reload Then
            grid.DataBind()
        End If
    End Sub

 

When I change the dropdown from the masterpage to a different language, it changes all the other values in the resx file except the page text. The really weird part is, if I change the dropdown value again it then updates the pager text to what it should have been the first time. So in other words

1. change from english to french. All the text from the resx file EXCEPT the PagerText changes.

2. Change back to English. All the text from the english rex file change correctly, and the pagertext now changes to the french pager text from the resx file. 

Could this have something to do with the asp update panel?

3 Answers, 1 is accepted

Sort by
0
Konstantin Dikov
Telerik team
answered on 19 Jul 2016, 10:49 AM
Hi Fred,

The OnNeedDataSource event seems to be too late in the page's life cycle and that is why the culture is changed on the second postback. I would suggest that you follow the approach from the following online demo for changing the culture:
As you will notice, you just need to change the RadioButtonList with the DropDownList control and initiate a postback when you change the selection in that control.

Hope this helps.


Regards,
Konstantin Dikov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
0
fred williams
Top achievements
Rank 1
answered on 19 Jul 2016, 03:37 PM

Hi,

Thanks for the reply. Will this work inside an asp update panel? The page I'm dealing with know wraps everything inside an update panel.

0
Konstantin Dikov
Telerik team
answered on 22 Jul 2016, 08:34 AM
Hello Fred,

If the DropDown control and the RadGrid are within the same UpdatePanel, the same approach should work correctly.

Just on a side note, if you have more complex scenario and you need more flexible AJAX settings on your page, you could take advantage of our RadAjaxManager control:


Best Regards,
Konstantin Dikov
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Grid
Asked by
fred williams
Top achievements
Rank 1
Answers by
Konstantin Dikov
Telerik team
fred williams
Top achievements
Rank 1
Share this question
or