protected void btnupdateStatus_Click(object sender, EventArgs e) { int Id = 0; Agent agentupdate = new Agent(); //lbleditusr Label lblAgentId = null; RadioButton rbGridWala = null; string enableStatus = ""; foreach (GridViewRow item in gvDetails.Rows) { rbGridWala = (RadioButton)item.FindControl("RBtnY"); if (rbGridWala.Checked == true) { enableStatus = "Y"; } else { enableStatus = "N"; } lblAgentId = (Label)item.FindControl("lblitemUsr"); int id = Convert.ToInt32(lblAgentId.Text); if (rbGridWala != null && lblAgentId != null) { adAgentBal.UpdateAgentStatusById(id, enableStatus); } } Response.Write("<script LANGUAGE='JavaScript' >alert('Agent Status Updated successfully')</script>"); BindAgentDetails(); }