why refreshing the page can result in duplicate entries into a data table?

Last post 06-20-2007 9:02 PM by garyding2003. 4 replies.

Sort Posts:

  • why refreshing the page can result in duplicate entries into a data table?

    06-20-2007, 12:11 AM
    • Member
      14 point Member
    • garyding2003
    • Member since 04-28-2006, 10:07 PM
    • Posts 54

    Hi,

    I have textboxes, sqldatasource and <asp:controlparameter> to insert new records into a a data table. I find a strange thing. After clicking a button to enter a record into the table successfully, I refresh the page and another same record is entered into the table(there are 2 the same records)!!!

    Please advise how to avoid this from happening?

     Gary 

     

     

    Thanks for reading and replying my answer.
  • Re: why refreshing the page can result in duplicate entries into a data table?

    06-20-2007, 1:07 AM
    • Contributor
      2,176 point Contributor
    • JRICE
    • Member since 05-11-2006, 12:52 AM
    • Lebanon-Beirut
    • Posts 667

    Reponse.Redirect(CurrentPage)--After insert

     

    HTH

    Please remember to "Mark As Answer" if this post answered your question!

    Bilal Shouman - MCAD.NET

    |My Blog|
    ---------------------------------


  • Re: why refreshing the page can result in duplicate entries into a data table?

    06-20-2007, 1:46 AM
    Answer
    • Member
      268 point Member
    • subhendude
    • Member since 02-28-2007, 12:21 PM
    • Posts 53

    Hi Friend,

     

    Check the article ... It will solve ur problem

     

    http://msdn2.microsoft.com/en-us/library/ms379557(vs.80).aspx

  • Re: why refreshing the page can result in duplicate entries into a data table?

    06-20-2007, 6:03 AM
    Answer
    • Member
      160 point Member
    • safeery2k
    • Member since 05-11-2007, 9:29 AM
    • Surrey, UK
    • Posts 37

    Actually whenever you refresh the page it requests the page against last event that was fired to the server. for example in your case you have button to postback and save the values to db. so when we click on that button it saves the values... that's fine :) but when you refresh the page after postback it will again fire the button postback event and will insert  a new record.

    So solution is to redirect to another page or same page after adding the values so that if one refresh the page it will not effect your logic

    Safeer Ahmad
    Cell: 07534181678
    Email: safeer.ahmad@yahoo.com
    LinkedIn: http://www.linkedin.com/in/safeerahmad
  • Re: why refreshing the page can result in duplicate entries into a data table?

    06-20-2007, 9:02 PM
    • Member
      14 point Member
    • garyding2003
    • Member since 04-28-2006, 10:07 PM
    • Posts 54

    Thanks for your kind help.

    Thanks for reading and replying my answer.
Page 1 of 1 (5 items)