473,228 Members | 1,771 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,228 software developers and data experts.

How to delete multiple rows in a GridView?

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)

Jun 27 '08 #1
2 5300
Hi Michael,

As for ASP.NET GridView control, the one-row based editing/updating is due
to its postback event processing mode. In that built-in postback processing
model, the edit/update/delete will only focus on a single row.

If you want to implement a multiple row based editing/deleting, you need to
use the default readonly mode and provide your own multi-row select
interface. For example, you can put an additional column in Gridview row
which contains a checkbox, and put an "delete" button in the GridView's
header or footer. In the postback event, you can manually loop through all
the GridViewRow to lookup the checkbox value in each row and determine
whether to perform deleting for the certain row.

Here are tow web articles that provide examples of add multi-row processing
in ASP.NET Gridview:

#Deleting Multiple Rows in a GridView
http://www.dotnetcurry.com/ShowArtic...ctCookieSuppor
t=1

#Allowing Users to Delete Rows in a GridView Control
http://authors.aspalliance.com/aspxt...owinguserstode
leterowsingridview.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>Reply-To: "Michael" <Mi**********@noemail.noemail>
From: "Michael" <Mi**********@noemail.noemail>
Subject: How to delete multiple rows in a GridView?
Date: Tue, 29 Apr 2008 11:01:25 +0800

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)

Jun 27 '08 #2
Thanks for the reply. It helps.
"Steven Cheng [MSFT]" <st*****@online.microsoft.comwrote in message
news:vF**************@TK2MSFTNGHUB02.phx.gbl...
Hi Michael,

As for ASP.NET GridView control, the one-row based editing/updating is due
to its postback event processing mode. In that built-in postback
processing
model, the edit/update/delete will only focus on a single row.

If you want to implement a multiple row based editing/deleting, you need
to
use the default readonly mode and provide your own multi-row select
interface. For example, you can put an additional column in Gridview row
which contains a checkbox, and put an "delete" button in the GridView's
header or footer. In the postback event, you can manually loop through all
the GridViewRow to lookup the checkbox value in each row and determine
whether to perform deleting for the certain row.

Here are tow web articles that provide examples of add multi-row
processing
in ASP.NET Gridview:

#Deleting Multiple Rows in a GridView
http://www.dotnetcurry.com/ShowArtic...ctCookieSuppor
t=1

#Allowing Users to Delete Rows in a GridView Control
http://authors.aspalliance.com/aspxt...owinguserstode
leterowsingridview.aspx

Hope this helps.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
ms****@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
--------------------
>>Reply-To: "Michael" <Mi**********@noemail.noemail>
From: "Michael" <Mi**********@noemail.noemail>
Subject: How to delete multiple rows in a GridView?
Date: Tue, 29 Apr 2008 11:01:25 +0800

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)

Jun 27 '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....
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: 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...
0
by: sharonrao123 | last post by:
hello all, I have a parent gridview company and in this one a nested gridview people, Is it possible to allow the user to select one row or multiple rows from the people gridview using a check box...
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...
3
by: =?Utf-8?B?S2F5xLFoYW4=?= | last post by:
In my project,i added datagridview to my form , i transfered my table to datagridview and added multiple rows and when i called dataadapther.update ,,result is ok. But when i tried it for the...
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...
2
by: =?Utf-8?B?QXN0cml0aA==?= | last post by:
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...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, youll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.