开发者

Edit data with Linq to Sql in asp.net

I have an accounts table in my database (firstname, lastname, address, etc) and I need to display that on my asp.net page, BUT i need to enable editing also.

I have tried using GridView, DetailsView etc, and none of them seem to enable editing? I am sure i am doing something wrong开发者_运维技巧.

I am using linqdatasource which connects to my repository.

<asp:LinqDataSource ID="AccountDataSource" runat="server" 
ContextTypeName="Model.Core.Domain.DBDataContext" 
Select="new (Summary, Department, JobTitle)" TableName="Accounts" 
Where="AccountId == @AccountId" EnableUpdate="True" >
<WhereParameters>
    <asp:SessionParameter Name="AccountId" SessionField="accountId" Type="Int32" />
</WhereParameters>

any ideas. thanks


You have to explicitly enable update, insert, and delete on the datasource:

<asp:LinqDataSource ID="AccountDataSource" runat="server" 
EnableUpdate="true" 
EnableInsert="true" 
EnableDelete="true"
...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜