How to populate updatable FormView from EntityDataSource using filter

I am trying to create a member page to update account information. I want to fill out a form with member data, but I don’t know how to set a filter on EntityDataSource to limit the request.

When I set the select statement based on the identifier of the element, I get an error

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

I think this is because you cannot update the projection or something like that, but still around?

Or do I need to run a request in Page_Load and fill out the form myself?

+6
c # entity-framework formview entitydatasource
source share
1 answer

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

You can 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 using querystring. There are also several other types of parameters of the built-in type.

+13
source share

All Articles