public void DataBind() { CommunityAlert ca = new CommunityAlert(); List <CommunityAlert> caList = ca.GetAllCommunityPartnerAlertView(); gvAlerts.DataSource = caList; gvAlerts.DataBind(); }
public List <CommunityAlert> GetAllCommunityPartnerAlertView() { var reader = dbHelper.GetCommunityPartnerAlert(Constant.SP_CommunityPartnerAlertView); List <CommunityAlert> caList = new List <CommunityAlert>(); CommunityAlert ca = null; while (reader.Read()) { ca = new CommunityAlert(); ca.AlertID = Convert.ToInt32(reader["AlertID"]); ca.Message = reader["Message"].ToString(); ca.Date = Convert.ToDateTime(reader["Date"]); caList.Add(ca); } return(caList); }
protected void DeleteAlert(object sender, EventArgs e) { //Get the button that raised the event Button Delete = (Button)sender; //Get the row that contains this event GridViewRow gvr = (GridViewRow)Delete.NamingContainer; Label lblAlertID = ((Label)gvr.FindControl("lblAlertID")); Label lblCPID = ((Label)gvr.FindControl("lblCPID")); Label Message = ((Label)gvr.FindControl("lblMessage")); Label Date = ((Label)gvr.FindControl("lblDate")); //Datasource CommunityAlert ca = new CommunityAlert(); ca.AlertID = Convert.ToInt32(lblAlertID.Text); ca.DeleteAlertMessage(); //DataBind DataBind(); }