protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e) { Label l; l = (Label)GridView1.Rows[e.RowIndex].FindControl("lblCityId"); int CityId = 0; CityId = int.Parse(l.Text); CityBusinessLayer.DeleteCity(CityId); ShowCity(); lblMsg.Text = "City Deleted Successfully..."; }
protected void btnDelete_Click(object sender, EventArgs e) { CheckBox chk; foreach (GridViewRow gr in GridView1.Rows) { Label l; l = (Label)gr.FindControl("lblCityId"); int CityId = 0; CityId = int.Parse(l.Text); chk = (CheckBox)gr.FindControl("chkid"); if (chk.Checked == true) { CityBusinessLayer.DeleteCity(CityId); lblMsg.Text = "City Deleted Successfully..."; } else { lblMsg.Text = "No City Selected..."; } ShowCity(); } }