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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T09:26:12+00:00 2026-05-29T09:26:12+00:00

I need to build a web page with a DetailsView which has a bunch

  • 0

I need to build a web page with a DetailsView which has a bunch of text boxes and drop down lists which bind to an ObjectContainerDataSource. This is for one-way binding using the InsertItemTemplate.

I can easily get this working for both text boxes and drop down lists using statically-defined fields, however my particular situation requires the fields to be added at runtime as the web page needs to be highly configurable.

For textboxes, this is easy via the BoundField class, however it all goes horribly wrong when I try to use the TemplateField for a Drop Down List. I have tried many different methods, including writing my own TemplateField class, and also setting the InsertItemTemplate directly using CompiledBindableTemplateBuilder. But no matter what I do, the basic issue is after the insert button is clicked, TemplateFields do not bind to the object data source. I believe this is because the InsertItemTemplate is null on postback (note that when all fields are declared in mark-up, InsertItemTemplate is not null). If anyone has done exactly what I’m trying to do, please reply, because I am now at the end of my tether with this.

I’ve reverted back to the simple TextBox inside a template field for proof of concept, but it will not work either. I’ve pasted what I’ve done below. In this case I’m trying to bind the TextBox input to a property called “CustomerRef”. I think my issue may relate to how I’m setting the Text property, but I have not been able to find any other way to set the Text property to Bind(…) in code behind.

This is how I insert my templated field:

var tf = new TemplateField();
tf.InsertItemTemplate  = new CompiledBindableTemplateBuilder(delegate(Control container)
    {

        TextBox text = new TextBox();
        text.ID = "MyTextBoxId";
        text.Attributes.Add("Text", "<%# Bind(\"CustomerRef\") %>");
        container.Controls.Add(text);
    },
    delegate(Control container)
    {  // I've tried throwing an exception in here but it never gets executed

        OrderedDictionary dict = new OrderedDictionary();
        dict["CustomerRef"] = ((TextBox)container.Controls[0]).Text;
        return dict;
    });

And this is how I add the field to my DetailsView Fields list:

ShipmentSearchView.Fields.Add(tf);

I put some text in the textbox and press the insert button… then in my Event Handler for the insert event I try to get the data source like this:

 var dataSource = e.Instance as MyClassName;

At this point in debug environment I notice that the field in question no longer has the InsertItemTemplate – it is null, and MyCustomerRef is not set.

I have tried adding the fields in various places, in Page_Load() – both on every post back and only on first load; in Page_Init() and also in the Init() event of the Details View, but it never seems to make a difference how I do it. Thanks in advance for any help with this issue.

  • 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-29T09:26:12+00:00Added an answer on May 29, 2026 at 9:26 am

    I ended up writing my own custom user control to achieve this – it really isn’t that hard to do. If anyone is interested in my solution I’d be happy to post it here. But going by the lack of comments against my original post, I’m guessing that what I’m doing on my web page is not something many people are attempting!

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

Sidebar

Related Questions

I need to build a web page that has categorized data that looks like
I'm trying to incorporate this yui drop down menu control in a web page:
I'am new to symfony. I need to build a static web page. The page
I need to build a web application with different process flows and different UI
I have various web pages that need to build up a URL to display
I have Web page in share-point 2010 ,its has two web parts one for
I need to build a native app for iPhone which should be available in
I need build in web query capability similar to what you can do in
In one of my projects I need to build an ASP.NET page and some
I need to build web application that will do: build web pages. build template

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.