Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to delete Rows of a GridView?

Reply
Thread Tools

How to delete Rows of a GridView?

 
 
Astrith
Guest
Posts: n/a
 
      09-26-2008
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
AutoGenerateDeleteButton="True".

Now as i understand, i have to write code in the GridView1_RowDataBound and
GridView1_RowDeleting 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?

 
Reply With Quote
 
 
 
 
Lanoli Lanoli is offline
Junior Member
Join Date: Sep 2008
Posts: 2
 
      09-26-2008
In the delete handler :
Code:
Private Sub DataGridEigendom_r_RowDeleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewDeleteEventArgs) Handles DataGridEigendom_r.RowDeleting
remove the data you want to have removed from the source you are binding to the gridview and rebind.
 
Reply With Quote
 
 
 
 
miladhatam@gmail.com
Guest
Posts: n/a
 
      09-26-2008
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
 
Reply With Quote
 
Bogdan
Guest
Posts: n/a
 
      09-26-2008

"Astrith" <> wrote in message
news:FC4E3BCC-6774-4181-912A-...
>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
> AutoGenerateDeleteButton="True".
>
> Now as i understand, i have to write code in the GridView1_RowDataBound
> and
> GridView1_RowDeleting 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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Rows the rows of a grid view? Jason James ASP .Net 0 08-10-2006 09:24 PM
dynamically add new rows and save data typed in these rows to a database Arjen Hoekstra ASP .Net 0 08-02-2005 12:15 PM
convert rows to columns and columns to rows helpful sql ASP .Net 0 05-19-2005 06:03 PM
script for moving rows up and down and traverse thru rows of HTML table Subba Rao via DotNetMonster.com ASP .Net 0 03-19-2005 06:46 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57