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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T23:27:29+00:00 2026-05-19T23:27:29+00:00

I have a SalesOrderItem table, and it has a UnitPrice column in case the

  • 0

I have a SalesOrderItem table, and it has a UnitPrice column in case the salesperson wishes to override the unit price of the Product for that order item.

In an ASP.NET Dynamic Data application, what would be the best way to set that UnitPrice property on a new SalesOrderItem based on the standard UnitPrice for the product? In other words, when the user clicks New on the ‘Items’ screen for a sales order, the UnitPrice field should already be filled in with the normal unit price for the product.

  • 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-19T23:27:30+00:00Added an answer on May 19, 2026 at 11:27 pm

    If the UnitPrice default value was a constant, it would be as simple as setting the DefaultValueAttribute on the UnitPrice metadata column. Since the default value must be calculated at runtime, we have to take a different approach.

    It is not clear from the question how the Product record is located. Assuming it is available on the server when the Insert page is initially rendered, you could create a field template for the UnitPrice column. For the sake of example, let’s also assume that the column type of UnitPrice is decimal.

    Locate the field templates folder (by default in “~/DynamicData/FieldTemplates”). Using the Decimal_Edit.ascx* files as a guide, create a new set of field template files labeled “UnitPrice_Insert.ascx”, “UnitPrice_Insert.ascx.cs”, and “UnitPrice_Insert.ascx.designer.cs”. Use the code-behind file to calculate and set the default value:

    protected void Page_Init(object sender, EventArgs e) {
        decimal defaultUnitPrice;
        // Calculate and set the defaultUnitPrice here.
        // "this.Page" might be useful for locating the Product record.
        FieldValue = defaultUnitPrice;
    }
    

    Finally, annotate the metadata for the UnitPrice column to use the template that was just created:

    [UIHint("UnitPrice")]
    

    Now the Insert screen will use “UnitPrice_Insert.ascx” and thereby show the calculated default value, while the List, Details, and Edit screens will still use the “Decimal.ascx” and “Decimal_Edit.ascx” templates, which show the actual column value, not the default value.

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

Sidebar

Related Questions

Have following Java code,that creates StringBuilder with \n,i.e. carriage return delimiters: while (scanner.hasNextLine()){ sb.append(scanner.nextLine()).append(\n);
Have set up a small website for a client however contact form submissions are
Have been writing the shell script such as : #! /bin/bash `sqlplus -s <username>/<passwd>@dbname`
Have same challenge as this guy: How to copy dependencies to gae war/WEB-INF/lib Applying
have a wierd issue. for the life of me can't trace this back (its
Have a slight problem. Trying to post XML to a server. To do this,
Have been searching all over the internet but struggling to find my answer to
have tried a few different approaches to this but with no success so far.
Have a problem with fscanf() - it does not skip to the next word

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.