0

I have a dynamic data site, that records a project name and customer name. The Insert page works fine, but the edit page duplicates the edit fields. So on the edit page there will be:

Project Name : [TextBox]

Project Name :1 [TextBox]

On the Insert page however there is fine:

Project Name : [TextBox]

Any ideas?

Here is the Dynamic Data aspx Page Code:

<asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true">
    <DataControls>
        <asp:DataControlReference ControlID="FormView1" />
    </DataControls>
</asp:DynamicDataManager>

<h2 class="DDSubHeader">Edit Project</h2>

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
            HeaderText="List of validation errors" CssClass="DDValidator" />
        <asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="FormView1" Display="None" CssClass="DDValidator" />

        <asp:FormView runat="server" ID="FormView1" DataSourceID="DetailsDataSource" DefaultMode="Edit"
            OnItemCommand="FormView1_ItemCommand" OnItemUpdated="FormView1_ItemUpdated" RenderOuterTable="false">
            <EditItemTemplate>
                <table id="detailsTable" class="DDDetailsTable" cellpadding="6">
                    <asp:DynamicEntity ID="DynamicEntity1" runat="server" Mode="Edit" />
                    <tr class="td">
                        <td colspan="2">
                            <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Update" Text="Update" />
                            <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
                        </td>
                    </tr>
                </table>
            </EditItemTemplate>
            <EmptyDataTemplate>
                <div class="DDNoItem">No such item.</div>
            </EmptyDataTemplate>
        </asp:FormView>

        <asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableUpdate="true" />

        <asp:QueryExtender TargetControlID="DetailsDataSource" ID="DetailsQueryExtender" runat="server">
            <asp:DynamicRouteExpression />
        </asp:QueryExtender>
    </ContentTemplate>
</asp:UpdatePanel>

Here is the Code Behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.DynamicData;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Halcyonetic.TimeService.Web.DynamicData.CustomPages.Projects
{
public partial class Edit : System.Web.UI.Page
{
    protected MetaTable table;

    protected void Page_Init(object sender, EventArgs e)
    {
        table = DynamicDataRouteHandler.GetRequestMetaTable(Context);
        FormView1.SetMetaTable(table);
        DetailsDataSource.EntityTypeName = table.EntityType.AssemblyQualifiedName;
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        Title = table.DisplayName;

    }

    protected void FormView1_ItemCommand(object sender, FormViewCommandEventArgs e)
    {
        if (e.CommandName == DataControlCommands.CancelCommandName)
        {
            Response.Redirect(table.ListActionPath);
        }
    }

    protected void FormView1_ItemUpdated(object sender, FormViewUpdatedEventArgs e)
    {
        if (e.Exception == null || e.ExceptionHandled)
        {
            Response.Redirect(table.ListActionPath);
        }
    }
}
}

Here is my Data Annotations:

[MetadataType(typeof(ProjectMetadata))]
[ScaffoldTable(true)]
public partial class Project
{
}

[DisplayName("Projects")]
public partial class ProjectMetadata
{
    [Display(Name = "Project Name", Order = 1)]
    [ScaffoldColumn(true)]
    public object ProjectName { get; set; }

    [Display(Name = "Customer", Order = 2)]
    [ScaffoldColumn(true)]
    [UIHint("Customer")]
    public object Company { get; set; }
}
Halceyon
  • 299
  • 1
  • 4
  • 12

1 Answers1

0

What you have posted looks like standard dynamic data code, but you may want to look more closely at the relationships (mapped as associations) in your DBML or EDX file. It looks like the Edit template is doubly associating things....which is very strange. Sorry this is not specific, but maybe it would help.

Ash Machine
  • 9,601
  • 11
  • 45
  • 52
  • Thanks for the reply, it actually turned out there was a custom page for the edit screen defined, that had the double textboxes defined! – Halceyon Sep 26 '12 at 05:09