protected void grdArmy_ItemDatabound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { this.history = e.Item.DataItem as VNPT.Modules.EmployeesHistory.EmployeesHistoryInfo; Label lblOut = e.Item.FindControl("lblOut") as Label; if (lblOut != null) { lblOut.Text = String.Format("{0:dd/MM/yyyy}", this.history.todate); } Label lblIn = e.Item.FindControl("lblIn") as Label; if (lblIn != null) { lblIn.Text = String.Format("{0:dd/MM/yyyy}", this.history.fromdate); } ImageButton imgDelete = e.Item.FindControl("imgDelete") as ImageButton; if (imgDelete != null) { imgDelete.Attributes.Add("onClick", "javascript:return confirm('Bạn có muốn xóa');"); } Label lblEmployessName = e.Item.FindControl("lblEmployessName") as Label; if (lblEmployessName != null) { lblEmployessName.Text = objEmplyess.GetEmployees(this.history.employeeid).fullname; } HyperLink hplName = e.Item.FindControl("hplName") as HyperLink; if (hplName != null) { hplName.Text = objEmplyess.GetEmployees(this.history.employeeid).fullname;; } } }
protected void grdArmy_ItemCommand(object source, DataGridCommandEventArgs e) { int id = Int32.Parse(e.CommandArgument.ToString()); if (e.CommandName == "Delete") { this.history = objHistory.GetEmployeesHistory(id); objHistory.DeleteEmployeesHistory(this.history); this.grdArmy.DataSource = objHistory.GetEmployeesHistorys(); grdArmy.DataBind(); } }