Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. GridView adds duplicate row on Page refresh

GridView adds duplicate row on Page refresh

Scheduled Pinned Locked Moved ASP.NET
csshelpquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    Blumen
    wrote on last edited by
    #1

    Hi, I have a GridView with a FormView on its EmptyDataTemplate so that user can insert a row initially. I provide controls on Footer so that user can add rows from within the GridView. I also use inline editing and deletion. Datasource is SqlDataSource. Problem is that when I refresh the page duplicate row is added with previous data in the grid footer controls. I tried many ways to avoid it, I tried

    Page.IsValid

    (it returns true!), I tried to check for

    e.Command == "insert"

    , that too is correct. Even the

    TextBox.Text

    has values though it is empty after a manual insert operation. What am I doing wrong here? Regards, Blumen

    “Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.”

    S 1 Reply Last reply
    0
    • B Blumen

      Hi, I have a GridView with a FormView on its EmptyDataTemplate so that user can insert a row initially. I provide controls on Footer so that user can add rows from within the GridView. I also use inline editing and deletion. Datasource is SqlDataSource. Problem is that when I refresh the page duplicate row is added with previous data in the grid footer controls. I tried many ways to avoid it, I tried

      Page.IsValid

      (it returns true!), I tried to check for

      e.Command == "insert"

      , that too is correct. Even the

      TextBox.Text

      has values though it is empty after a manual insert operation. What am I doing wrong here? Regards, Blumen

      “Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.”

      S Offline
      S Offline
      Spunky Coder
      wrote on last edited by
      #2

      In the Insert command event,write the code which validates the data to check for the duplicates and then insert into the SqlDataSource. Update the gridview only if the transaction is successful.

      "Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)

      B 1 Reply Last reply
      0
      • S Spunky Coder

        In the Insert command event,write the code which validates the data to check for the duplicates and then insert into the SqlDataSource. Update the gridview only if the transaction is successful.

        "Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)

        B Offline
        B Offline
        Blumen
        wrote on last edited by
        #3

        Thank you, I appreciate that. I was looking for less-code approach :)

        “Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.”

        S 1 Reply Last reply
        0
        • B Blumen

          Thank you, I appreciate that. I was looking for less-code approach :)

          “Last night I lay in bed looking up at the stars in the sky and I thought to myself, where the heck is the ceiling.”

          S Offline
          S Offline
          Spunky Coder
          wrote on last edited by
          #4

          Ok! Find it out and let me know :)

          "Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups