locked
localize eval("ColumnName") RRS feed

  • Question

  • User-1571109499 posted

    I have a label

    <asp:Label ID="LBLExcuse" runat="server" Text='<%# Eval("ColName") %>'
                            meta:resourcekey="LBLExcuseResource1"></asp:Label>


    my table contain ID,ArabicName,EnglishName columns

    I need to bind with ArabicName or EnglishName according to resx file that translate ColName

    I use VB.Net, VS 2010 , EF

     Thanks in advance

    Sunday, November 28, 2010 5:15 AM

Answers

  • User-231977777 posted

    hi

    try something like this :

    <asp:Label Text='<%# System.Threading.Thread.CurrentThread.CurrentUICulture.Name.ToLower()  == "ar-eg" ? Eval("ArabCol") : Eval("EnglishCol") %>' runat="server" />


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 28, 2010 8:09 AM
  • User-231977777 posted

     

    but if i change the culture after the page has been loaded

    the the line of code Text=   '<%# IIF (System.Threading.Thread.CurrentT  .......%>'

    will not run again and will still remember its last value

    hi

    call DataBind Method to your DataBoundControl  like this :

    in my Example iam putting this label in gridView and when i click a button it will do the following :

       protected void Button1_Click(object sender, EventArgs e)
        {
            this.UICulture = "ar-eg";
            GridView1.DataBind();
        }
    

    and notice that i am setting Culture="en-us" in page Directive .

    this should work

    Hope this helps


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 28, 2010 8:59 AM

All replies

  • User-231977777 posted

    hi

    try something like this :

    <asp:Label Text='<%# System.Threading.Thread.CurrentThread.CurrentUICulture.Name.ToLower()  == "ar-eg" ? Eval("ArabCol") : Eval("EnglishCol") %>' runat="server" />


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 28, 2010 8:09 AM
  • User-1571109499 posted

    Thanks Ahmed that is working for me

    my code now looks like

    <asp:Label ID="LBLExcuseEnglishName" runat="server" Text=   '<%# IIF (System.Threading.Thread.CurrentThread.CurrentUICulture.Name.ToLower()  = "ar-eg" , Eval("Excuse.ArabicName") , Eval("Excuse.EnglishName")) %>'
    meta:resourcekey="LBLExcuseEnglishNameResource1"></asp:Label>

    but if i change the culture after the page has been loaded

    the the line of code Text=   '<%# IIF (System.Threading.Thread.CurrentT  .......%>'

    will not run again and will still remember its last value

    Sunday, November 28, 2010 8:42 AM
  • User-231977777 posted

     

    but if i change the culture after the page has been loaded

    the the line of code Text=   '<%# IIF (System.Threading.Thread.CurrentT  .......%>'

    will not run again and will still remember its last value

    hi

    call DataBind Method to your DataBoundControl  like this :

    in my Example iam putting this label in gridView and when i click a button it will do the following :

       protected void Button1_Click(object sender, EventArgs e)
        {
            this.UICulture = "ar-eg";
            GridView1.DataBind();
        }
    

    and notice that i am setting Culture="en-us" in page Directive .

    this should work

    Hope this helps


     

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Sunday, November 28, 2010 8:59 AM
  • User-1571109499 posted

    Thanks Alot Ahmed


    Sunday, November 28, 2010 9:15 AM