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

  • Home
  • SEARCH
  • 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 6379093
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:05:38+00:00 2026-05-25T02:05:38+00:00

It seems that controls like BoundField only work inside data binding containers like e.g.

  • 0

It seems that controls like BoundField only work inside data binding containers like e.g. a GridView, where there is repeating data. I would like to know how to code something like a BoundField that will work e.g. inside the ItemTemplate of a data bound FormView. Just look how much more readable the MyFormViewBoundField is below compared to the raw template way of doing this.

The current way of doing it:

<ItemTemplate>
    <div class="span-12 last">
        <dl class="name-value">
            <dt>Property Type</dt>
            <dd><%# Eval("property_type_full") %></dd>
        </dl>
    </div>
</ItemTemplate>

Compared to what I wish to do:

<ItemTemplate>
    <div class="span-12 last">
        <mystuff:MyFormViewBoundField LabelText="PropertyType" DataValueField="property_type_full" />
    </div>                
</ItemTemplate>
  • 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-05-25T02:05:38+00:00Added an answer on May 25, 2026 at 2:05 am

    You can do this with a simple server Control and customise as required.

    public class DataBindField : CompositeControl
    {
        private HtmlGenericControl dt;
        private HtmlGenericControl dd;
    
        public string LabelText { get; set; }
    
        public string DataValueField { get; set; }
    
        protected override void OnDataBinding(EventArgs e)
        {
            EnsureChildControls();
            base.OnDataBinding(e);
    
            object dataItem = DataBinder.GetDataItem(NamingContainer);
            if (dataItem != null)
            {
               dd.InnerText = DataBinder.Eval(dataItem, DataValueField) as string;
            }
            dt.InnerText = LabelText;
        }
    
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            var dl = new HtmlGenericControl("dl");
            dt = new HtmlGenericControl("dt");
            dd = new HtmlGenericControl("dd");
    
            dl.Controls.Add(dt);
            dl.Controls.Add(dd);
    
            Controls.Add(dl);
        }
    }
    

    Obviously adding support for ViewState or design-time support requires more work, but that’s the basics.

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

Sidebar

Related Questions

I have a concept for a framework of controls that I would like to
It seems to me that Response.Cache.SetVaryByCustom(mykey); is not working from within ASCX User Controls.
Seems that requirements on safety do not seem to like systems that use AI
Forgive me for being a little naive perhaps, but it seems that System.Windows.Controls.DataVisualization.Charting has
I would like to add reporting capabilities to a .NET application. My data source
It seems that CListCtrl doesn't send mouse up events unless there is a double
It seems that I can't control the NSApp delegate from within a System Preferences
It seems to me that the Ribbon control has a problem with textboxes. I
I can't seem to be able to disable ViewState for controls that I add
The ribbon control seems to be the rage now that Windows 7 is here.

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.