473,405 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,405 software developers and data experts.

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
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?

Sep 26 '08 #1
2 2287
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
Sep 26 '08 #2

"Astrith" <As*****@discussions.microsoft.comwrote in message
news:FC**********************************@microsof t.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
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
Sep 26 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: NateDawg | last post by:
I'm reposting this. I'm kinda in a bind untill i get this figured out, so if anyone has some input it would sure help me out. Ok, I’ve noticed a few gridview problems floating around the forum....
4
by: MasterChief | last post by:
I am trying to learn how to delete multple items in a database using the code behind file. I would just like somebody to tell me what is wrong with my code. I am new to connecting to the database...
1
by: J055 | last post by:
Hi I have a GridView which includes the ability to delete rows. This works fine accept for when a naughty user decides to refresh the browser thereby posting the same delete command instruction....
0
by: David C | last post by:
I have a GridView with a Delete link and wondered where the best place was to check and cancel delete of a row/record that is bound to an SqlDatasource. I can use datasource Deleting event or...
2
by: Blasting Cap | last post by:
I've got a gridview (that I converted over from a datagrid, which had been working properly), that is doubling up the number of rows returned. When it was running as a datagrid, the same code sent...
2
by: cmrhema | last post by:
hello, i am new to asp.net. i am trying to do a simple application of adding,inserting and deleting rows in gridview. i am using C#.net and javascript. My edit/update works but i have...
1
by: officegeek | last post by:
I have a gridview that is populated via page_load. I can get the delete to work but get an error after it deletes. The error is below the index value that is returned is the one that is deleted...
2
by: Michael | last post by:
It seems that a gridview allows us to delete only a single row at a time. How to extend this functionality to select multiple rows and delete all of the selected rows in a single stroke? just like...
0
by: Andy B | last post by:
I have a GridView in asp.net. I want to set its datasource to some xml content. At the same time, I need to know how to insert/delete/edit content in the GridView rows and then repopulate the xml...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.