How to delete multiple rows in a GridView?

M

Michael

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)
 
S

Steven Cheng [MSFT]

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/ShowArticle.aspx?ID=66&AspxAutoDetectCookieSuppor
t=1

#Allowing Users to Delete Rows in a GridView Control
http://authors.aspalliance.com/aspxtreme/webforms/controls/allowinguserstode
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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
 
M

Michael

Thanks for the reply. It helps.


Steven Cheng said:
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/ShowArticle.aspx?ID=66&AspxAutoDetectCookieSuppor
t=1

#Allowing Users to Delete Rows in a GridView Control
http://authors.aspalliance.com/aspxtreme/webforms/controls/allowinguserstode
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:
(e-mail address removed).

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.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/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no
rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,040
Latest member
papereejit

Latest Threads

Top