views:

17

answers:

1

I'm trying to figure out why I can edit just fine inside my gridview, but my delete command yields a server error.

The error message I get on the AJAX postback on a delete is as follows:


208|error|500|A property named 'Member.fullname' was not found on the entity during an insert, update, or delete operation. Check to ensure that properties specified as binding expressions are available to the data source.|


This does not happen when I do an Edit command, which works just fine.

I have 3 entities (Task, Member, Project).

In my Gridview to display the Task table I have template fields set up to display user-friendly data instead of id numbers:

<asp:GridView ID="TaskList" runat="server" DataSourceID="TaskSource" DataKeyNames="id" 
    AutoGenerateColumns="False">
    <Columns>
        <asp:TemplateField AccessibleHeaderText="Name" HeaderText="Name" >
            <EditItemTemplate>
                <asp:DropDownList ID="ddlMemberName" runat="server" DataSourceID="MemberSource" 
                    DataTextField="fullname" DataValueField="id" SelectedValue='<%# Bind("member_id") %>'>
                </asp:DropDownList>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="lblMemberName" runat="server" Text='<%# Bind("Member.fullname") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField AccessibleHeaderText="Task" HeaderText="Task">
            <EditItemTemplate>
                <asp:TextBox ID="txtMemberTask" runat="server" Text='<%# Bind("description") %>' 
                    TextMode="MultiLine"></asp:TextBox>
            </EditItemTemplate>
            <ItemTemplate>
                <asp:Label ID="lblMemberTask" runat="server" Text='<%# Bind("description") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />    
    </Columns>
</asp:GridView>

I have my EntityDataSources set up like this:

<asp:EntityDataSource ID="TaskSource"
    DefaultContainerName="webteamEntities" runat="server"
    ConnectionString="name=webteamEntities" EnableDelete="True"
    EnableFlattening="False" EnableInsert="True" EnableUpdate="True" 
    EntitySetName="Tasks" Include="Project, Member" />
<asp:EntityDataSource ID="MemberSource"
    DefaultContainerName="webteamEntities" runat="server"
    ConnectionString="name=webteamEntities"
    EnableFlattening = "False"
    EntitySetName="Members" />

So if my datakeynames="id" why is it even trying to access Member.fullname on delete? And even at that...why does my edit work just fine?

Am I missing something?

A: 

It wouldn't harm replacing Bind with Eval in your Item templates. Bind is 2 way. Eval is 1 way. Since you're only showing data in your Item templates Eval would suffice.

Jeroen
Thank you, perfect
Shadyn