Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8211963
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T10:36:19+00:00 2026-06-07T10:36:19+00:00

I am trying to create localization for my ASP.NET code, but I have issues

  • 0

I am trying to create localization for my ASP.NET code, but I have issues setting the TemplateField’s HeaderText

I have this that works

                        <asp:TemplateField HeaderText="Description">
                        <ItemTemplate>
                            <%# Eval("Description") %>
                        </ItemTemplate>
                        <FooterTemplate>
                            <asp:Panel ID="Panel5" runat="server" DefaultButton="EditSubmission">
                                <asp:TextBox runat="server" ID="Submission_DescriptionTxtBox" TextMode="MultiLine"
                                ToolTip='<%# GetById("atforbedringsforslag_description_tooltip") %>'/>

                                </asp:Panel>
                        </FooterTemplate>
                    </asp:TemplateField>

But I want to change

<asp:TemplateField HeaderText="Description">

To

<asp:TemplateField HeaderText='<%# GetById("atforbedringsforslag_description_title") %>'>

But then I get

Databinding expressions are only supported on objects that have a DataBinding event. System.Web.UI.WebControls.TemplateField does not have a DataBinding event.

How should I set this field? I can find some that uses OnRowCreated, but then you access the fields with an index number, and then it becomes easy to make mistakes or forgot to change indexes if new fields are added later on


EDIT My solution:

Created the custom expression builder

using System.Web.Compilation;
using System;
using System.CodeDom;

public class LocalizationExpressionBuilder : ExpressionBuilder
{
    public override CodeExpression GetCodeExpression(System.Web.UI.BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
    {
        CodeExpression[] inputParams = new CodeExpression[] { new CodePrimitiveExpression(entry.Expression.Trim()), 
                                                    new CodeTypeOfExpression(entry.DeclaringType), 
                                                    new CodePrimitiveExpression(entry.PropertyInfo.Name) };

        // Return a CodeMethodInvokeExpression that will invoke the GetRequestedValue method using the specified input parameters 
        return new CodeMethodInvokeExpression(new CodeTypeReferenceExpression(this.GetType()),
                                    "GetRequestedValue",
                                    inputParams);
    }

    public static object GetRequestedValue(string key, Type targetType, string propertyName)
    {
        // If we reach here, no type mismatch - return the value 
        return GetByText(key);
    }

    //Place holder until database is build
    public static string GetByText(string text)
    {
        return text;
    }
}

Added the prefix to my web.config

<system.web>
<compilation debug="true" defaultLanguage="c#" targetFramework="4.0">
  <expressionBuilders>
    <add expressionPrefix="localizeByText" type ="LocalizationExpressionBuilder"/>
  </expressionBuilders>
    </compilation>
</system.web>

And I can now get my text like this

<asp:TemplateField HeaderText='<%$ localizeByText:Some text %>'>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T10:36:21+00:00Added an answer on June 7, 2026 at 10:36 am

    You can build your own custom Expression Builder which calls your GetById method. Look at the following link for an old but good article explaining how to build an expression builder and how to use it:

    https://web.archive.org/web/20210304125044/https://www.4guysfromrolla.com/articles/022509-1.aspx

    When you have an expression builder, you use it with the <%$ syntax. This is different from the databinding syntax <%#.

    For the HeaderText field, it is not allowed to use DataBinding syntax (not sure why, but that’s how MS made it). Using expression syntax IS allowed and will work once you have your custom expression builder done.

    Do go through the page I linked to, it’s quite a lot of text, but in the end making you expression builder will not take much effort…

    Also, the page has a link at the bottom to a library of expression builder that the author has made. Have a look at them, maybe one of them could be used directly to solve your problem (specifically, the CodeExpressionBuilder).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying create a template with django but when I execute this sentences in
Trying to create a black line in my view to separate text blocks but
Trying to create a new Dedicated Cache Role in Windows Azure but get the
Trying to create a background-image slideshow and am getting this error... This is the
hi I'm trying create chat using node.js I see example in http://chat.nodejs.org/ I have
I'm trying create a RCP Application with Eclipse, but I can't get past the
I'm trying create a box in my Django app that displays text (and possibly
I'm trying create a ASMX webservice that can perform a HTTP GET request. I
I'm trying create a new file with a Java Applet, but I don't know
I am trying create a small web application that allows a user to login

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.