/ Published in: ASP
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
Here's the source code of the detailsview and objectdatasource: <asp:ObjectDataSource ID="CustomerDetailDataSource" runat="server" DataObjectTypeName="Customer" DeleteMethod="Delete" SelectMethod="GetCustomerByID" TypeName="CustomerManager" UpdateMethod="UpdateCustomer"> <SelectParameters> <asp:Parameter DefaultValue="0" Name="ID" Type="Int32" /> </SelectParameters> </asp:ObjectDataSource> <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataSourceID="CustomerDetailDataSource" DefaultMode="Edit"> <Fields> <asp:BoundField DataField="fname" HeaderText="fname" SortExpression="fname" /> <asp:BoundField DataField="lname" HeaderText="lname" SortExpression="lname" /> <asp:BoundField DataField="email" HeaderText="email" SortExpression="email" /> <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" ReadOnly="true"/> <!-- WITHOUT THE NEXT LINE, VERSION IS NULL WHEN UPDATING THE ENTITY, WITH THE NEXT LINE I GET AN EXCEPTION WHEN UPDATING --> <asp:BoundField DataField="version" HeaderText="version" SortExpression="version" ReadOnly="true"/> </Fields> </asp:DetailsView> This is what I call in my updatebutton's event handler: DetailsView1.UpdateItem(true);