public void loadDetails() { //this function will load the data into grid myDAL objDAL = new myDAL(); if (Session["type"] != null) // means currently admin { string Email = Session["user"].ToString(); Details.DataSource = objDAL.GetAdminDetails_DAL(Email); Details.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (IsPostBack) { return; } if (Request.QueryString["campaignID"] == null) { var page = ServiceContext.GetPageBySiteMarkerName(Website, "Event Listings"); Response.Redirect(ServiceContext.GetUrl(page)); } Details.DataSource = new[] { Campaign }; Details.DataBind(); var registrationButton = (Button)Details.FindControl("RegisterButton"); var message = (Label)Details.FindControl("Message"); if (Campaign.MSA_StartDateTime > DateTime.Now) { switch (Campaign.StatusCode.Value) { case 200001: registrationButton.Text = "Register for this Event"; message.Text = "*Event is waitlisted"; break; case 200002: registrationButton.Visible = false; message.Text = "This event is Sold Out."; break; default: registrationButton.Text = "Register for this Event"; break; } } else { registrationButton.Visible = false; message.Text = "*Event occurs in the past"; } }
protected void Update_Click(object sender, EventArgs e) { DetailsPanels.DataBind(); DetailsPanels.Visible = true; UpdateDetails.Visible = false; //set up object to use the web.config file string connectionString = WebConfigurationManager.ConnectionStrings["photocatconnection"].ConnectionString; //set up connection object called 'myConnection' SqlConnection myConnection = new SqlConnection(connectionString); //open database communication myConnection.Open(); string fupdate = fnameedit.Text; string supdate = snameedit.Text; string eupdate = emailedit.Text; string pupdate = passedit.Text; int row = int.Parse(Request.QueryString["UserID"]); string query = "UPDATE Users SET Forename = @newf, Surname = @news, Email = @newe, Password = @newp WHERE UserID = @id"; SqlCommand myCommand = new SqlCommand(query, myConnection); //parameterised object myCommand.Parameters.AddWithValue("@newf", fupdate); myCommand.Parameters.AddWithValue("@news", supdate); myCommand.Parameters.AddWithValue("@newe", eupdate); myCommand.Parameters.AddWithValue("@newp", pupdate); myCommand.Parameters.AddWithValue("@id", row); myCommand.ExecuteNonQuery(); Details.DataBind(); myConnection.Close(); }