473,667 Members | 2,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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?

Sep 26 '08 #1
2 2315
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*****@discus sions.microsoft .comwrote in message
news:FC******** *************** ***********@mic rosoft.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
Sep 26 '08 #3

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

Similar topics

3
13741
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. Everyone wants to do a java confirmation box when a user clicks the delete button. Fair enough, basic user design rules state that you should always confirm a delete action. There is also a consensus that the best way to do this is a template...
4
2160
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 through a code-behind. I have a gridview called gridview1. When the user checks a bunch of plans then should be able to hit delete and for each checked box it should delete the plan and update the gridview1. Imports System.Data Imports...
1
4126
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. The problem with this is that the refresh will either delete another record or generate an exception, something like this: An error has occurred because a control with id 'ctl00$Main$UserGrid$ctl11$ctl00' could not be located
0
1415
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 GridView_RowDeleting event. I need to get 2 values from the row I am trying to delete so I can perform another function returns whether I can delete the record or not. I am trying to do this in gridview event (see code below) but it is not working....
2
2110
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 back the proper number of rows. The only thing different I am doing is to display the number of rows returned in the footer of the gridview. The Bindgrid is as follows: Sub BindGrid() Session("reportlevel") = Session("availabilityrptlevel")
2
2447
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 problems in deleting the rows in the datagrid. i have used command fields(properties-columns) edit,update,cancel and delete commands. i changed it to template field. both are as buttons. ihave changed the id of Delete command to btDelete. The...
1
5754
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 so that is why I think I get an error. Any help would be great. I am in the process of moving from classic ASP to .NET so i am not well versed yet. Index was out of range. Must be non-negative and less than the size of the collection....
2
5332
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 what hotmail web UI is doing now (having the option of selecting multiple rows (using the checkbox provided) and perform a set of operations on them)
0
1221
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 source to reflect the changes made in the gridView. Is there any simple examples of doing something like this or can somebody create one for me? Thanks for the help...
0
8790
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8570
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8650
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5677
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4372
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2781
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2017
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1779
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.