473,395 Members | 1,608 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,395 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 5310
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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.