Hi all, I am binding a detailsview with objectdatasource which gets the select parameter from the querystring. The detailsview shows the desired record, but when I try to update it, my update method gets the old values for the record (and hence no update). here is my detailsview code:
<asp:DetailsView ID="dvUsers" runat="server" Height="50px" Width="125px"
AutoGenerateRows="False" DataSourceID="odsUserDetails"
onitemupdating="dvUsers_ItemUpdating">
<Fields>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="Username" HeaderText="Username" SortExpression="Username"
ReadOnly="true" />
<asp:BoundField DataField="FirstName" HeaderText="First Name" SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="Last Name" SortExpression="LastName" />
<asp:BoundField DataField="Email" runat="server" HeaderText="Email" SortExpression="Email" />
<asp:BoundField DataField="IsActive" HeaderText="Is Active" SortExpression="IsActive" />
<asp:BoundField DataField="IsOnline" HeaderText="Is Online" SortExpression="IsOnline"
ReadOnly="true" />
<asp:BoundField DataField="LastLoginDate" HeaderText="Last Login" SortExpression="LastLoginDate"
ReadOnly="true" />
<asp:BoundField DataField="CreateDate" HeaderText="Member Since" SortExpression="CreateDate"
ReadOnly="true" />
<asp:TemplateField HeaderText="Membership Ends" SortExpression="ExpiryDate">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ExpiryDate") %>'></asp:TextBox>
<cc1:CalendarExtender ID="TextBox1_CalendarExtender" runat="server" Enabled="True"
TargetControlID="TextBox1">
</cc1:CalendarExtender>
</EditItemTemplate>
<InsertItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ExpiryDate") %>'></asp:TextBox>
</InsertItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("ExpiryDate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Fields>
and here is the objectdatasource code:
<asp:ObjectDataSource ID="odsUserDetails" runat="server" SelectMethod="GetAllUserDetailsByUserId"
TypeName="QMS_BLL.Membership" UpdateMethod="UpdateUserForClient">
<UpdateParameters>
<asp:Parameter Name="User_ID" Type="Int32" />
<asp:Parameter Name="firstName" Type="String" />
<asp:Parameter Name="lastName" Type="String" />
<asp:SessionParameter Name="updatedByUser" SessionField="userId" DefaultValue="1" />
<asp:Parameter Name="expiryDate" Type="DateTime" />
<asp:Parameter Name="Email" Type="String" />
<asp:Parameter Name="isActive" Type="String" />
</UpdateParameters>
<SelectParameters>
<asp:QueryStringParameter DefaultValue="1" Name="User_ID" QueryStringField="User_ID"
Type="Int32" />
</SelectParameters>
</asp:ObjectDataSource>
Is the OnItemUpdating method still required when you have your custom BLL method called on insertevent? (which is being executed fine in my case but updating with the old values) or am I missing something else?
Also I tried to provide an OnItemUpdating method and in there I tried to capture the contents of the textboxes (the new values). I got an exception: "Specified argument was out of the range of valid values. Parameter name: index"
when I tried to do:
TextBox txtFirstName = (TextBox)dvUsers.Rows[1].Cells[1].Controls[0];
Any help will be most appreciated.