Hello,
I am binding Gridview with suppose 1000 records. I need to add checkbox infront of each row and user will check any checkbox they want and There should be common APPROVE button. On clicking on it, it should update status of CHECKED rows only
| Choose | Reference Id | Status | Action |
|---|---|---|---|
| checkbox1 | 12345 | Y | APPROVE |
| checkbox2 | 78945 | Y | APPROVE |
| checkbox3 | 74185 | Y | APPROVE |
| checkbox4 | 85296 | Y | APPROVE |
APPROVE
User can either update single record or multi-rows record (Checked row)
Thanks in Advance !

Vishal YelveRank #178 · 13.6K reputationPosted Nov 11, 2024, 10:45 PM EST
Hi,
Do refer below links
https://www.aspsnippets.com/Articles/524/GridView-with-CheckBox-Get-Selected-Rows-in-ASPNet/
https://www.c-sharpcorner.com/blogs/add-checkbox-in-asp-gridview-with-select-all-functionality
Sangeetha SRank #212 · 11.4K reputationPosted Nov 14, 2024, 5:31 AM EST
Hi,
c#
bind data to the GridView on page load
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
BindGrid();
}
}
private void BindGrid()
{
// Replace with your data source
var dataSource = GetData(); // Fetch your data here
GridView1.DataSource = dataSource;
GridView1.DataBind();
}
on select of check box
protected void btnSubmit_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox chkSelect = (CheckBox)row.FindControl("chkSelect");
if (chkSelect != null && chkSelect.Checked)
{
// Process the selected row
string selectedValue = row.Cells[1].Text; // Adjust index based on your columns
// Add your logic here
}
}
}