/// <summary> /// Executes logic for each row in the Repeater as it is bound. /// </summary> /// <param name="Sender"></param> /// <param name="e"></param> protected void RegistrationRepeater_ItemDataBound(Object Sender, RepeaterItemEventArgs e) { // Execute the following logic for Items and Alternating Items. if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { // Hide all rows initially--they will be made visible if they meet certain criteria. e.Item.Visible = false; // Get the promotionId for the current row. int intPromoId; // If the promotionId is a valid number, then continue. bool result = Int32.TryParse(((DataRowView)e.Item.DataItem)["promotion_request_id"].ToString(), out intPromoId); if (result) { SqlDataReader PromoSqlDataReader = new PromotionRequestData().GetPromotionRequestByID(intPromoId, ArenaContext.Current.Organization.OrganizationID); // Get the ordinal number of the "event_id" column. int intEventIdColumn = PromoSqlDataReader.GetOrdinal("event_id"); // Confirm that the SqlDataReader has returned rows of data before continuing. if (PromoSqlDataReader.HasRows) { // Begin reading rows of data and perform actions upon each one. while (PromoSqlDataReader.Read()) { if (!PromoSqlDataReader.IsDBNull(intEventIdColumn)) { // Create an EventProfile object based on the event id in the current row. // An EventProfile object contains methods which return properties for an event. EventProfile eventProfile1 = new EventProfile(PromoSqlDataReader.GetInt32(intEventIdColumn)); // Determine if the event's type is to be displayed. if (ItemIsEventType(eventProfile1.Type.LookupID)) { if (itemCounter < maxItems) { // The item meets all criteria--make the row visible. e.Item.Visible = true; itemCounter = itemCounter + 1; // Use the EventProfile object to display data about the event in the current row. ((Label)e.Item.FindControl("StartDateLabel")).Text = ShowStartDateLabel(eventProfile1.Type.LookupID) ? HiddenDateSetting : DateTimeExtensions.ToShortDateString(eventProfile1.Start, true); ((Label)e.Item.FindControl("TopicAreaLabel")).Text = eventProfile1.TopicArea.Value; // Uncomment the following line for debugging in development only. //((Label)e.Item.FindControl("TopicAreaLabel")).Text += " | " + eventProfile1.Type.Value + " | " + ItemIsEventType(eventProfile1.Type.LookupID).ToString() + " | " + ShowStartDateLabel(eventProfile1.Type.LookupID).ToString() + " | " + DatelessEventTypeIDSetting.ToString(); } } } } } PromoSqlDataReader.Close(); } } }
/// <summary> /// Update the information displayed in the datagrid. /// </summary> private void ShowList() { DataTable table = new PromotionRequestData().GetPromotionWebList_DT(true, -1); String[] topicAreas; // // Filter out rows we don't want. We only want rows that are promoted in the correct areas. // if (!String.IsNullOrEmpty(TopicAreaSetting)) { topicAreas = TopicAreaSetting.Split(','); // // Walk each row in the table and process all rows that are not marked as deleted. // foreach (DataRow row in table.Rows) { if (row.RowState != DataRowState.Deleted) { bool flag = false; string[] strArray = row["cross_promote_values"].ToString().Split(new char[] { ',' }); // // We start with flag = false and look for a match on each of the possible // topic areas. // foreach (String area in topicAreas) { // // If the primary topic area matches, set flag = true so it will be kept. // if (area.Trim() == row["topic_area_luid"].ToString()) { flag = true; } // // Check if topic area against the secondary topic areas. If we find a match // set flag = true so the row will be kept. // foreach (string str in strArray) { if (str == area.Trim()) { flag = true; } } } // // If no topic area match was found, delete the row. // if (!flag) { row.Delete(); } } } table.AcceptChanges(); } // // Setup all the parameters for the datagrid. // dgPromotions.AllowPaging = false; dgPromotions.PagerStyle.Visible = false; dgPromotions.ItemType = "Display Request"; dgPromotions.ItemBgColor = base.CurrentPortalPage.Setting("ItemBgColor", string.Empty, false); dgPromotions.ItemAltBgColor = base.CurrentPortalPage.Setting("ItemAltBgColor", string.Empty, false); dgPromotions.ItemMouseOverColor = base.CurrentPortalPage.Setting("ItemMouseOverColor", string.Empty, false); dgPromotions.AddEnabled = false; dgPromotions.DeleteEnabled = true; dgPromotions.DeleteIsAsync = false; dgPromotions.EditEnabled = false; dgPromotions.MergeEnabled = false; dgPromotions.MailEnabled = false; dgPromotions.ExportEnabled = true; dgPromotions.DataSource = table; dgPromotions.DataBind(); }