0% found this document useful (0 votes)
67 views3 pages

Enhancing Gridview Using Jquery When Deleting Mulitple Rows - Part 29

This document discusses enhancing a GridView control in ASP.NET using jQuery when deleting multiple rows. It describes handling deleting rows without a selection by showing an alert, and confirming deletion when rows are selected. The code provided removes auto postback and checked change handlers, and adds JavaScript to toggle row selection based on a header checkbox and update the header checkbox based on row selections.

Uploaded by

shradha11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
67 views3 pages

Enhancing Gridview Using Jquery When Deleting Mulitple Rows - Part 29

This document discusses enhancing a GridView control in ASP.NET using jQuery when deleting multiple rows. It describes handling deleting rows without a selection by showing an alert, and confirming deletion when rows are selected. The code provided removes auto postback and checked change handlers, and adds JavaScript to toggle row selection based on a header checkbox and update the header checkbox based on row selections.

Uploaded by

shradha11
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

8/28/2017 Sql server, .

Sql server, .net and c# video tutorial: Enhancing gridview using jquery when deleting mulitple rows - Part 29

More Next Blog Create Blog Sign In

Sql server, .net and c# video tutorial


Free C#, .Net and Sql server video tutorial for beginners and intermediate programmers.

Support us .Net Basics C# SQL ASP.NET ADO.NET MVC Slides C# Programs Subscribe Buy DVD

Enhancing gridview using jquery when deleting mulitple rows - Part 29

Suggested Videos
Part 26 - Displaying summary data in asp.net gridview footer
Part 27 - EmptyDataText and EmptyDataTemplate properties of asp.net gridview control
Part 28 - Delete mulitple rows from asp.net gridview
Best software training and placements in
marathahalli, bangalore. For further
details please call 09945699393.

Please watch Part 28 - Delete mulitple rows from asp.net gridview from gridview tutorial
CBSE Class 9 Maths
before proceeding with this video.
Number Systems

Let us use Javascript to toggle the selection of checkboxes in gridview, instead of


using server side code. This improves performance and user experience. CPT Tutorial
Part 1 : Video | Text | Slides

Important Videos
When the user clicks the delete button, without selecting any rows, we should get a
The Gift of Education
javascript alert box as shown below.
Web application for your business

How to become .NET developer

Resources available to help you

Dot Net Video Tutorials


Angular 2 Tutorial

Design Patterns

ASP.NET Web API

Bootstrap

AngularJS Tutorial

When I click delete after selecting a few rows, we should get a javascript confirmation jQuery Tutorial
dialog box as shown below.
JavaScript with ASP.NET Tutorial

JavaScript Tutorial

Charts Tutorial

LINQ

LINQ to SQL

LINQ to XML

Entity Framework

http://csharp-video-tutorials.blogspot.in/2013/03/enhancing-gridview-using-jquery-when.html 1/5
8/28/2017 Sql server, .net and c# video tutorial: Enhancing gridview using jquery when deleting mulitple rows - Part 29
WCF

ASP.NET Web Services

Dot Net Basics

C#

SQL Server

ADO.NET

ASP.NET

GridView

ASP.NET MVC

Delete "AutoPostBack" and "oncheckedchanged" attributes from Visual Studio Tips and Tricks
"HeaderTemplate" and "ItemTemplate"
Dot Net Interview Questions

Slides
Entity Framework

WCF

ASP.NET Web Services

Dot Net Basics

C#

SQL Server

ADO.NET

ASP.NET

GridView

ASP.NET MVC
Delete the following 2 methods from code-behind file
Visual Studio Tips and Tricks
protected void cbDelete_CheckedChanged(object sender, EventArgs e)
protected void cbDeleteHeader_CheckedChanged(object sender, EventArgs e)
Java Video Tutorials
Copy and paste the following javascript code in the HEAD section of Part 1 : Video | Text | Slides
WebForm1.aspx
<script type="text/javascript" language="javascript"> Part 2 : Video | Text | Slides
function toggleSelectionUsingHeaderCheckBox(source) {
Part 3 : Video | Text | Slides
$("#GridView1 input[name$='cbDelete']").each(function () {
$(this).attr('checked', source.checked);
}); Interview Questions
} C#

function toggleSelectionOfHeaderCheckBox() { SQL Server


if ($("#GridView1 input[name$='cbDelete']").length == $("#GridView1
input[name$='cbDelete']:checked").length) { Written Test
$("#GridView1 input[name$='cbDeleteHeader']").first().attr('checked', true);
}
else {
$("#GridView1 input[name$='cbDeleteHeader']").first().attr('checked', false);
}
}

$(document).ready(function () {

http://csharp-video-tutorials.blogspot.in/2013/03/enhancing-gridview-using-jquery-when.html 2/5
8/28/2017 Sql server, .net and c# video tutorial: Enhancing gridview using jquery when deleting mulitple rows - Part 29
$("#btnDelete").click(function () {
var rowsSelected = $("#GridView1 input[name$='cbDelete']:checked").length;
if (rowsSelected == 0) {
alert('No rows selected');
return false;
}
else
return confirm(rowsSelected + ' row(s) will be deleted');
});
});
</script>

Finally associate toggleSelectionUsingHeaderCheckBox() method with onclick


event of CheckBox - cbDeleteHeader and toggleSelectionOfHeaderCheckBox()
method with onclick event of CheckBox - cbDelete.

3 comments:

Rvn Lord August 14, 2014 at 7:14 AM


Thank you so much for this excellent tutorials sir, however if sb got problems like me,
with jqyery functions not working properly, try this code:

function toggleSelectionUsingHeaderCheckBox(source) {
$("#GridView1 input[name$='cbDelete']").each(function () {
$(this).prop('checked', source.checked);
});
}

function toggleSelectionOfHeaderCheckBox() {

http://csharp-video-tutorials.blogspot.in/2013/03/enhancing-gridview-using-jquery-when.html 3/5

You might also like