How to retain the gridview cell color when language is changed to French

Abbai, Srividhyavathi 21 Reputation points
2022-09-13T19:16:28.107+00:00

I have a web appln. which is rendered both in English and French lang. The issue I'm facing is when we change the language to french my gridview loses it's cell formatting. I have provided the gridview template field below. The error and warning class associated to lbldeliverdate is not applying on language change. Based on cell value the deliver date cell will change icon to Red icon-Danger class and Warning icon-Warning class. This logic is handled in code behind. Not sure why it isn't working on French Translation. Any help?`

    <asp:TemplateField HeaderText="$Deliver date">  
        <ItemTemplate>  
            <div id="DIV_Error" runat="server" class="fa fa-exclamation-circle text-danger" visible="false"></div>  
            <div id="DIV_Warning" runat="server" class="fa fa-exclamation-triangle text-warning" visible="false"></div>  
            <a href="test.aspx"><asp:Label ID="lbldeliverdate" runat="server" Text=""></asp:Label></a>  
        </ItemTemplate>  
    </asp:TemplateField>  

`

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,451 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Michael Taylor 53,571 Reputation points
    2022-09-13T19:45:16.13+00:00

    CSS class styling is independent of the language. In fact the language is just an HTTP header so it wouldn't have any impact on rendering unless your code does something with it.

    You mentioned that your code behind is doing something but it is unclear exactly what. If your server code is responsible for determining whether to apply the CSS classes or not then it becomes a matter of checking the rendered HTML. If the classes are missing then your server side code has an issue (most likely with the date formatting). You should debug your server side code.

    If the CSS classes are in the HTML but the browser isn't rendering them then use the Developer Tools (F12) in the browser. Select your element and confirm the browser sees the CSS. You can also see what rules are being applied for the CSS to confirm that it is actually rendering the correct styling for the class.

    0 comments No comments

  2. SurferOnWww 2,661 Reputation points
    2022-09-14T00:57:45.803+00:00

    When you set the Culture and UICulture to auto something like bellow, the ASP.NET will see the Accept-Language header in the request and set the culture of the thread which processes the request according to the setting in the Accept-Language header.

    <%@ Page Language="C#" Culture="auto" UICulture="auto" %>  
    

    Try to check it using th following code:

    protected void Page_Load(object sender, EventArgs e)  
    {  
        CultureInfo ci = Thread.CurrentThread.CurrentUICulture;  
        Label1.Text = "CultureInfo: " + ci.ToString();  
    }  
    

    If the language set in the browser is French you will see the result as follows:

    CultureInfo: fr-FR

    So I suggest that you set "the gridview cell color" according to the CultureInfo obtained as above.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.