By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,483 Members | 3,261 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,483 IT Pros & Developers. It's quick & easy.

How to delete multiple rows in a GridView?

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.