Get the App
SLTechnology News&Howtos  ›  Development  › 

How to delete using checkbox in ASP.NET Gridview

Shulou Source: shulou.com Published: 2022-06-03 06:17:54 11月17日 Update

This article mainly introduces ASP.NET Gridview in how to use checkbox delete, the text is very detailed, has a certain reference value, interested friends must read!

Method 1:

Background Code:

protected void btn_delete_Click(object sender, EventArgs e)

{

for (int i = 0; i 0)

{

ClientScript.RegisterStartupScript(GetType(),"Prompt","alert ('Delete succeeded! ')");

}

else

{

ClientScript.RegisterStartupScript(GetType(), Prompt, alert ('Delete failed! ')");

}

this.DataBind();

}

}

}

}

}

}

Front Desk:

.Hidden

{

display:none;

}

Add a new column, this column binds the id field, and the visable attribute cannot be false, otherwise the value cannot be obtained.

checkbox Select all functions:

function change(sender) {

var table = document.getElementById("GridView1");

for (var i = 1; i < table.rows.length; i++) {

table.rows[i].cells[1].getElementsByTagName("input")[0].checked = sender.checked;

}

}

Tags: Tips success code content foreground background fields properties methods articles plus one value interests functions guys partners more knowledge industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Docker Redmi Shulou Technology Shulou Information macOS