How to delete Rows of a GridView?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?QXN0cml0aA==?=

    How to delete Rows of a GridView?

    I am a Newbie and i am scratching my head over how to delete a Row from a
    GridView.

    I have this GridView which has 3 fields called ID,ProjCode and
    ProjDescription of which ID is the hidden field. I have also set the property
    AutoGenerateDel eteButton="True ".

    Now as i understand, i have to write code in the GridView1_RowDa taBound and
    GridView1_RowDe leting METHODS to perform deletion of row. I have been
    searching for long for the code but no luck.

    Can sombody help me in deleting the rows of my Gridview?

  • miladhatam@gmail.com

    #2
    Re: How to delete Rows of a GridView?

    hi
    it is so clear , you must push the delete buttton ... :)
    you should delete that record from your db
    gridview just is a control that show your records
    i think you don't have any Primary Key in your Table

    Comment

    • Bogdan

      #3
      Re: How to delete Rows of a GridView?


      "Astrith" <Astrith@discus sions.microsoft .comwrote in message
      news:FC4E3BCC-6774-4181-912A-03AAE13D5F35@mi crosoft.com...
      >I am a Newbie and i am scratching my head over how to delete a Row from a
      GridView.
      >
      I have this GridView which has 3 fields called ID,ProjCode and
      ProjDescription of which ID is the hidden field. I have also set the
      property
      AutoGenerateDel eteButton="True ".
      >
      Now as i understand, i have to write code in the GridView1_RowDa taBound
      and
      GridView1_RowDe leting METHODS to perform deletion of row. I have been
      searching for long for the code but no luck.
      >
      Can sombody help me in deleting the rows of my Gridview?
      >
      Generally, deleting a row from your data source will also delete a
      corresponding row from your gridview, provided that the data source is bound
      to the gridview afterwards.

      Binding could be 'automatic' if you have a Delete button (as you mentioned
      above) and have a data source with a DeleteMethod defined in your aspx and
      referenced by the gridview .

      If your data source is not defined/referenced as stated above then you need
      to do the deletion and rebinding 'manually' in RowDeleting event handler.

      RowDataBound handler is not needed although it is quite often used to attach
      a client script to the delete button so a user is prompted to confirm the
      deletion.

      Bogdan


      Comment

      Working...