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. Grid delete problem

Grid delete problem

Scheduled Pinned Locked Moved ASP.NET
questioncssdatabasehelp
5 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.
  • C Offline
    C Offline
    Commickey
    wrote on last edited by
    #1

    I have a datagrid with a delete function... my problem is that the table in the database have three keys... how do I set the datakey value in this regard to be able to delete? Thanks alot, commickey

    P 1 Reply Last reply
    0
    • C Commickey

      I have a datagrid with a delete function... my problem is that the table in the database have three keys... how do I set the datakey value in this regard to be able to delete? Thanks alot, commickey

      P Offline
      P Offline
      Praveen_S
      wrote on last edited by
      #2

      1. Bind all three keys to the datagrid. 2. In ItemCommand event of datagrid , check for delete command eg.. switch(e.CommandName) { case "Delete": break; } 3. In the case "Delete" Find the controls and fetch values from the three key columns if you use a Template column for them in datagrid. eg. TextBox txt = new TextBox(); txt = (TextBox)e.Item.FindControl("txtKey1"); OR IF these three key columns are BoundColumn in datagrid then get values using following eg. e.Item.Cells[3] 4. Once you get all three key values you can delete this record by developing a sql query which will use these values to delete the record. praveen.

      C 3 Replies Last reply
      0
      • P Praveen_S

        1. Bind all three keys to the datagrid. 2. In ItemCommand event of datagrid , check for delete command eg.. switch(e.CommandName) { case "Delete": break; } 3. In the case "Delete" Find the controls and fetch values from the three key columns if you use a Template column for them in datagrid. eg. TextBox txt = new TextBox(); txt = (TextBox)e.Item.FindControl("txtKey1"); OR IF these three key columns are BoundColumn in datagrid then get values using following eg. e.Item.Cells[3] 4. Once you get all three key values you can delete this record by developing a sql query which will use these values to delete the record. praveen.

        C Offline
        C Offline
        Commickey
        wrote on last edited by
        #3

        Thanks Praveen.... Your solution looks right.... I will try it and let you know.... Greetings, Commickey

        1 Reply Last reply
        0
        • P Praveen_S

          1. Bind all three keys to the datagrid. 2. In ItemCommand event of datagrid , check for delete command eg.. switch(e.CommandName) { case "Delete": break; } 3. In the case "Delete" Find the controls and fetch values from the three key columns if you use a Template column for them in datagrid. eg. TextBox txt = new TextBox(); txt = (TextBox)e.Item.FindControl("txtKey1"); OR IF these three key columns are BoundColumn in datagrid then get values using following eg. e.Item.Cells[3] 4. Once you get all three key values you can delete this record by developing a sql query which will use these values to delete the record. praveen.

          C Offline
          C Offline
          Commickey
          wrote on last edited by
          #4

          Hello Praveen, Where do I do the number 4? in the itemCommand or the datagrid_delete function? Thanks alot, Commickey

          1 Reply Last reply
          0
          • P Praveen_S

            1. Bind all three keys to the datagrid. 2. In ItemCommand event of datagrid , check for delete command eg.. switch(e.CommandName) { case "Delete": break; } 3. In the case "Delete" Find the controls and fetch values from the three key columns if you use a Template column for them in datagrid. eg. TextBox txt = new TextBox(); txt = (TextBox)e.Item.FindControl("txtKey1"); OR IF these three key columns are BoundColumn in datagrid then get values using following eg. e.Item.Cells[3] 4. Once you get all three key values you can delete this record by developing a sql query which will use these values to delete the record. praveen.

            C Offline
            C Offline
            Commickey
            wrote on last edited by
            #5

            Praveen... thank... I worked around in the itemCommand it fires as I clicked on the delete button.... thanks alot.... it works now....

            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