protected void btnBlock_Click(object sender, EventArgs e) { foreach (GridViewRow r in GridView1.Rows) { int intBlockVal = 0; CheckBox chk = (CheckBox)r.Cells[0].FindControl("chkBlockStatus"); if (chk.Checked) { intBlockVal = 1; } string sAdId = GridView1.DataKeys[r.RowIndex].Value.ToString(); objAd = new AdDetailsBll(); objAd.UpdateAdBlockStatus(Convert.ToInt32(sAdId), intBlockVal); } //lblMessage.Visible = true; //lblMessage.Text = "Selected Ads are blocked"; }