views:

973

answers:

1

I'm trying to create a member page for updating account details. I want to populate a form with the member's data, but I don't know how to set a filter on the EntityDataSource to limit the query.

When I set the select statement based on the member ID, I get the error

Select cannot be set if EnableDelete, EnableInsert, or EnableUpdate is enabled.

I think this is because you can't update a projection or something, but is there anyway around this?

Or do I have to run a query in Page_Load and populate the form myself?

+4  A: 

There is no need to set the select, only the where clause.

You could do something like the following:

<asp:EntityDataSource ID="MyDataSource" EntitySetName="Entity1" runat="server"
    ConnectionString="name=MyEntitiesConnString" EnableUpdate="true"
    DefaultContainerName="MyEntities" Where="it.MemberId= @MemberId" >
        <WhereParameters>
            <asp:QueryStringParameter DbType="Int32" Name="memberId" QueryStringField="memberid" />
        </WhereParameters>
</asp:EntityDataSource>

If the parameter is passed in by querystring. there are several other built-int parameter types as well.

Merritt