private void dgRequests_ItemCommand(object source, DataGridCommandEventArgs e) { HtmlInputHidden hidRequestId = (HtmlInputHidden)e.Item.FindControl("hidRequestId"); if (hidRequestId != null) { int requestId = Convert.ToInt32(hidRequestId.Value); switch (e.CommandName.ToLower()) { case "edit": Response.Redirect("AddUpdateDriverRequest.aspx?requestId=" + requestId.ToString()); break; case "delete": Facade.IDriverRequest facDriverRequest = new Facade.Resource(); if (facDriverRequest.Delete(requestId, ((Entities.CustomPrincipal)Page.User).UserName)) { lblConfirmation.Text = "The request has been deleted."; } else { lblConfirmation.Text = "The request has not been deleted."; } lblConfirmation.Visible = true; FilterRequests(); break; } } }