protected void grdUser_ItemCommand(object source, DataGridCommandEventArgs e) { string strCA = e.CommandArgument.ToString(); switch (e.CommandName) { case "Edit": Insert = false; Id = strCA; List <CityInfo> Listcity = CityService.CityInfo_GetById(Id); //List<DataAccess.User> listE = UserService.User_GetById(Id); //Level = listE[0].Level.Substring(0, listE[0].Level.Length - 5); txtCityID.Text = Listcity[0].CityCode; txtCityName.Text = Listcity[0].CityName; //txtName.Text = listE[0].Name; //txtUsername.Text = listE[0].Username; //txtPassword.Text = ""; //Password = listE[0].Password; //txtAdmin.Text = listE[0].Admin; //txtOrd.Text = listE[0].Ord; //chkActive.Checked = listE[0].Active == "1" || listE[0].Active == "True"; pnView.Visible = false; pnUpdate.Visible = true; break; case "Delete": CityService.CityInfo_Delete(strCA); BindGrid(); break; } }
protected void DeleteButton_Click(object sender, EventArgs e) { DataGridItem item = default(DataGridItem); for (int i = 0; i < grdUser.Items.Count; i++) { item = grdUser.Items[i]; if (item.ItemType == ListItemType.AlternatingItem | item.ItemType == ListItemType.Item) { if (((CheckBox)item.FindControl("ChkSelect")).Checked) { string strId = item.Cells[1].Text; CityService.CityInfo_Delete(strId); } } } grdUser.CurrentPageIndex = 0; BindGrid(); }