using System; using System.Web.UI; using System.Web.UI.WebControls; using UG.Profiles; public partial class Home : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (Session["MainUserID"] != null) { lblWelcome.Text = "Welcome " + Session["MainUserName"].ToString() + "
Prepare for Draft Domination"; } else { Response.Redirect("Default.aspx"); } if (!Page.IsPostBack) { BindGrid(); } } private void BindGrid() { Profiles objProfile = new Profiles(); if (Session["MainUserID"] != null) { objProfile.UserID = Int32.Parse(Session["MainUserID"].ToString()); gvProfile.DataSource = objProfile.GetProfile(); gvProfile.DataBind(); } else { Response.Redirect("Default.aspx"); } } protected void gvProfile_RowDeleting(object sender, GridViewDeleteEventArgs e) { Profiles objProfile = new Profiles(); try { objProfile.DraftID = int.Parse(gvProfile.DataKeys[e.RowIndex].Value.ToString()); if (objProfile.DeleteProfile()) { BindGrid(); } } catch (Exception ex) { Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.ExceptionPolicy.HandleException(ex, "Business Exception Policy"); throw ex; } } protected void gvProfile_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { LinkButton lnkDelte = (LinkButton)e.Row.FindControl("lnkDelte"); lnkDelte.Attributes.Add("onclick", "return confirm(\"Are you sure want to delete profile - " + DataBinder.Eval(e.Row.DataItem, "DraftName") + "?\")"); } } }