Friday, August 21, 2009

Datagrid ASP.NET C#

Inside the datagrid, insert a template column with the checkbox name chkSelect. The next column should be the ID of the column you want to obtain information from.

protected void btnModify_Click(object sender, EventArgs e)
{
for (int i = 0; i < couponGrid.Rows.Count; i++)
{
GridViewRow row = couponGrid.Rows[i];
bool isChecked = ((CheckBox)row.FindControl("chkSelect")).Checked;
if (isChecked)
{
// Column 2 is the ID column
String accessId = couponGrid.Rows[i].Cells[1].Text;
lbl.Text = lbl.Text + "haha" + accessId;
}
}
}
}

No comments: