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 8142603
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T12:52:09+00:00 2026-06-06T12:52:09+00:00

You know if you’re working with Repeater Controls you’re not able to access the

  • 0

You know if you’re working with Repeater Controls you’re not able to access the controls the generic way (as far as I know). So we try to use const strings for most situations we have to work with strings in C#.

So I’ve made a class with const strings. They define the ID names of the Controls inside a repeater. That makes it possible to access the controls in a more generic way than using the plain strings in code. Example:

public class FormularRepeaterFieldIDs
{
    public const string RubrikLiteral = "BuchungRubrikLiteral";
    public const string RubrikDropDownList = "BuchungRubrikList";
    public const string RubrikIdHiddenField = "BuchungRubrikIdHidden";
}

Which enables access like this (of course you could make a easier access wrapper for this):

                Literal rubrikLiteral = (Literal)e.Item.FindControl(TimeExpressHelper.FormularRepeaterFieldIDs.RubrikLiteral);
                rubrikLiteral.Visible = false;

Now I would also be cool to use the predefined IDs in Webforms Frontend code. It looks this at the moment:

<asp:Literal ID="BuchungRubrikLiteral" Text='<%#Eval("strRubrik")%>' runat="server" />

Would it be possible to make something like this?

<asp:Literal ID="<% FormularRepeaterFieldIDs.RubrikLiteral %>" Text='<%#Eval("strRubrik")%>' runat="server" />
  • 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-06T12:52:11+00:00Added an answer on June 6, 2026 at 12:52 pm

    You could probably make this work with a custom ExpressionBuilder. Something like:

      <asp:Literal ID="<%$ Const:FormularRepeaterFieldIDs.BuchungRubrik" 
         Text='<%#Eval("strRubrik")%>' runat="server" />
    

    with a ExpressionBuilder that uses Reflection and/or a CodeSnippetExpression to read the value:

      class ConstExpressionBuilder : ExpressionBuilder {
           override bool SupportsEvaluate { get { return true; } }
    
           override CodeExpression GetCodeExpression(BoundPropertyEntry entry, ...) {
               return new CodeSnippetExpression(entry.Expression);
           }
    
           override object EvaluateExpression(BoundPropertyEntry entry, ...) {
               var splitExpression = entry.Expression.Split('.');
               var fieldName = splitExpression.Last();
               var typeName = entry.Expression.Substring(entry.Expression.Length - fieldName.Length - 1);
               var type = Type.GetType(typeName);
               return type.GetField(fieldName).GetValue(null);
           }
      }
    

    and a web.config to register it to handle the Const prefix:

      <expressionBuilders>
         <add expressionPrefix="Const" type="ConstExpressionBuilder" />
      </expressionBuilders>
    

    Or, you could take advantage of the existing ResourceExpressionBuilder, and make them resources instead of constants.

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

Sidebar

Related Questions

Know if it's possible to access the iPhone compass in Safari using JavaScript? I
I know you can not set a key value dynamically, but what about the
I know how to use the search feature on JQGrid where you send the
I know of cufon and one other similar. But what is the best way
I know the title is confusing so I'll try to explain better. Here's basically
I KNOW I did this in WP7 (not WP7.1) and I can't figure out
Know of a way to mock %[]? I'm writing tests for code that makes
Know of any tutorials or resources to configure Openfire Server to use it's built
I know that this may be common knowledge, but is there a way to
I know that I can use ProxyPass to serve up my yardoc server instance

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.