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 in asp.net 2.0

Gridview in asp.net 2.0

Scheduled Pinned Locked Moved ASP.NET
helpcsharpcssasp-netdatabase
8 Posts 3 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.
  • M Offline
    M Offline
    Milind Panchal
    wrote on last edited by
    #1

    Hi, I am working on gridview. while deleting the record i am getting the error as Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index my code is protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int empid=0; empid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } please give me what is the syntax for it. can any one help me urgently thanks!

    N 2 Replies Last reply
    0
    • M Milind Panchal

      Hi, I am working on gridview. while deleting the record i am getting the error as Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index my code is protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int empid=0; empid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } please give me what is the syntax for it. can any one help me urgently thanks!

      N Offline
      N Offline
      nandhububbly
      wrote on last edited by
      #2

      Hi change ur rowindex value or empid value after that u will get other wise reply to me i will give code for u .. Reg Nantha

      N M 2 Replies Last reply
      0
      • N nandhububbly

        Hi change ur rowindex value or empid value after that u will get other wise reply to me i will give code for u .. Reg Nantha

        N Offline
        N Offline
        N a r e s h P a t e l
        wrote on last edited by
        #3

        Hi, Set e.EditEndex=-1 After deleting the row.

        Naresh Patel

        1 Reply Last reply
        0
        • N nandhububbly

          Hi change ur rowindex value or empid value after that u will get other wise reply to me i will give code for u .. Reg Nantha

          M Offline
          M Offline
          Milind Panchal
          wrote on last edited by
          #4

          thanks your guidance.:rose: can u send me code please

          N 1 Reply Last reply
          0
          • M Milind Panchal

            thanks your guidance.:rose: can u send me code please

            N Offline
            N Offline
            N a r e s h P a t e l
            wrote on last edited by
            #5

            protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int empid=0; empid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); e.EditIndex=-1; }

            Naresh Patel

            1 Reply Last reply
            0
            • M Milind Panchal

              Hi, I am working on gridview. while deleting the record i am getting the error as Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index my code is protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int empid=0; empid = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } please give me what is the syntax for it. can any one help me urgently thanks!

              N Offline
              N Offline
              nandhububbly
              wrote on last edited by
              #6

              Hi try this ... protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int n = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); int empid=n-1; cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } in case not working send full functionality about this grid view process

              N 1 Reply Last reply
              0
              • N nandhububbly

                Hi try this ... protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { int n = Convert.ToInt32(GridView1.DataKeys[e.RowIndex]); int empid=n-1; cmd = new SqlCommand("delete employee where empid='" + empid + "'", con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); } in case not working send full functionality about this grid view process

                N Offline
                N Offline
                N a r e s h P a t e l
                wrote on last edited by
                #7

                I am giving you only Idea, not implementation. Ok

                Naresh Patel

                M 1 Reply Last reply
                0
                • N N a r e s h P a t e l

                  I am giving you only Idea, not implementation. Ok

                  Naresh Patel

                  M Offline
                  M Offline
                  Milind Panchal
                  wrote on last edited by
                  #8

                  very thank you Naresh Patel

                  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