Last post Oct 31, 2012 08:39 PM by Decker Dong - MSFT
Oct 31, 2012 06:19 AM|vikash12|LINK
when page is loaded for the first time and when i do add new contact the insert method from ods is firing properly,.becuase i am using objectdatasource.insert() method in button click(),it is not fired automatically from ODS method. but when i update the
contact first and then add new contact ,the insert event is fired twice,that time i guess from odscontact.insert() method from button click and 2nd automatically from the ods,
i cant figure out why it is calling the second time after updating any rcord,and not when i go first time to the page,
<asp:ObjectDataSource ID="odsContact" runat="server" SelectMethod="GetContactInfo"
UpdateMethod="UpdateContactInfo" InsertMethod="AddNewContact" OnUpdated="odsContact_OnUpdated"
above is my object source code,
and on button click for add new i am writing below this code
protected void btnSave_Click(object sender, EventArgs e)
}please help me in this if anyone knows the solution to the problem?
Oct 31, 2012 07:55 AM|Nakor|LINK
What kind of databound control are you using with your ObjectDataSource? Where is your button on the page? If the save button is in the databound control and has a CommandArgument of "Insert" then it will already be trying to execute the Insert method, if
you then try to handle the click event and call the Insert method then it would be getting called twice. But other than taking a shot in the dark there's no way to really know what's going on without seeing more of the code.
Oct 31, 2012 08:46 AM|vikash12|LINK
Thanks for your reply nakor!
I have two save buttons! one in insert templete and one in edit template
and both are having command argument as insert
<asp:Button ID="btnSave" runat="server" Text="Save" OnClientClick="submit_click_set_pwdscore()" CommandName="Insert"
This above one is in edit template and
<asp:Button ID="btnSave" runat="server" CommandName="Insert"
meta:resourcekey="btnSaveResource2" OnClientClick="submit_click_set_pwdscore()" OnClick="btnSave_Click" Text="Save"
and this one is in insert template.
Both the insert and edit template are inside aspformview
and after aspforrmview i have my object data source.
Oct 31, 2012 08:39 PM|Decker Dong - MSFT|LINK
Have you refreshed the whole page after inserting?