protected void tripDelete_Click(object sender, EventArgs e) { string DBConnect = ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString; SqlConnection myConn = new SqlConnection(DBConnect); LinkButton tripDelete = sender as LinkButton; GridViewRow row = tripDelete.NamingContainer as GridViewRow; //string ProgCode = Convert.ToString(GridViewTrip.DataKeys[row.RowIndex].Value.ToString()); string ProgCode = row.Cells[0].Text; int result; myConn.Open(); SqlCommand cmd = new SqlCommand("DELETE FROM Trip WHERE TripID ='" + ProgCode + "'", myConn); result = cmd.ExecuteNonQuery(); myConn.Close(); if (result == 1) { trip tripOjb = new trip(); tripDAO tripDAO = new tripDAO(); List <trip> tripList = new List <trip>(); tripList = tripDAO.getTripInfo(); GridViewImmTrip.DataSource = tripList; GridViewImmTrip.DataBind(); } //Response.Redirect("Tripmanagement.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if (!this.IsPostBack) { trip tripOjb = new trip(); tripDAO tripDAO = new tripDAO(); List <trip> tripList = new List <trip>(); tripList = tripDAO.getTripInfo(); TripList.DataSource = tripList; TripList.DataBind(); } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { trip tripOjb = new trip(); tripDAO tripDAO = new tripDAO(); //tripOjb = tripDAO.getTripById(1); //Lbl_country.Text = tripOjb.Country; //Lbl_description.Text = tripOjb.Description; List <trip> tripList = new List <trip>(); tripList = tripDAO.getTripInfo(); GridViewTrip.DataSource = tripList; GridViewTrip.DataBind(); List <trip> tripHist = new List <trip>(); tripHist = tripDAO.getTripHist(); GridViewHist.DataSource = tripHist; GridViewHist.DataBind(); } if (Session["Username"] == null) { } }