views:

30

answers:

2

i have an instance of ObjectDataSource with specified update method. But on update i have an old values(previously set in gridview) in method - they are not updating.

 <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="DeletePayment"
                        InsertMethod="InsertPayment" SelectMethod="GetPayments" TypeName="CostsReportControl.Models.Payments"
                        UpdateMethod="UpdatePayment" OldValuesParameterFormatString="{0}_old">
                        <SelectParameters>
                            <asp:Parameter Direction="input" Type="string" Name="sortExpression" />
                            <asp:Parameter Direction="input" Type="string" Name="sortDirection" />
                        </SelectParameters>
                        <DeleteParameters>
                            <asp:Parameter Name="id" Type="Int32" />
                        </DeleteParameters>
                    </asp:ObjectDataSource>
                    <asp:ObjectDataSource ID="ObjectDataSource2" runat="server" 
                        SelectMethod="GetList" TypeName="CostsReportControl.Models.PaymentTypes">
                    </asp:ObjectDataSource>

my update method

public void UpdatePayment(int Id,string Fullname,DateTime Date, string Sum, string PaymentType, string RecordInfo,int Id_old)
A: 

I will point out 2 things, these might be helpful to you.

OldValuesParameterFormatString="{0}_old"

Change to OldValuesParameterFormatString="{0}"

Please check 2nd thing, check whether your update method is called or not?

if not called, then call it manually in DetailView1_Updating event

DetailView1.Update();
Muhammad Akhtar
i changed OldValuesParameterFormatStringand there are the same old values.yes it is called, thats how i check that parameters are old
4e4el
A: 

Another thing to notice is, are you using Bind method to bind your inputs? if not please use that to automatically populate the new values collection

another thing I will suggest is, add and updating event for object data source and see what params are there in new values.

lakhlaniprashant.blogspot.com
hey the problem was with bind which i call on page_load
4e4el