private void dlstVote_ItemDataBound(object sender, DataListItemEventArgs e) { if ((e.Item.ItemType == ListItemType.Item) || (e.Item.ItemType == ListItemType.AlternatingItem)) { long voteId = Convert.ToInt64(this.dlstVote.DataKeys[e.Item.ItemIndex]); VoteInfo voteById = SubsiteStoreHelper.GetVoteById(voteId); IList <VoteItemInfo> voteItems = SubsiteStoreHelper.GetVoteItems(voteId); for (int i = 0; i < voteItems.Count; i++) { if (voteById.VoteCounts != 0) { voteItems[i].Percentage = decimal.Parse(((voteItems[i].ItemCount / voteById.VoteCounts) * 100M).ToString("F", CultureInfo.InvariantCulture)); } else { voteItems[i].Percentage = 0M; } } GridView view = (GridView)e.Item.FindControl("grdVoteItem"); if (view != null) { view.DataSource = voteItems; view.DataBind(); } } }
private void dlstVote_ItemDataBound(object sender, System.Web.UI.WebControls.DataListItemEventArgs e) { if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem) { long voteId = System.Convert.ToInt64(this.dlstVote.DataKeys[e.Item.ItemIndex]); VoteInfo voteById = SubsiteStoreHelper.GetVoteById(voteId); System.Collections.Generic.IList <VoteItemInfo> voteItems = SubsiteStoreHelper.GetVoteItems(voteId); for (int i = 0; i < voteItems.Count; i++) { if (voteById.VoteCounts != 0) { decimal num = voteItems[i].ItemCount / voteById.VoteCounts * 100m; voteItems[i].Percentage = decimal.Parse(num.ToString("F", System.Globalization.CultureInfo.InvariantCulture)); } else { voteItems[i].Percentage = 0m; } } System.Web.UI.WebControls.GridView gridView = (System.Web.UI.WebControls.GridView)e.Item.FindControl("grdVoteItem"); if (gridView != null) { gridView.DataSource = voteItems; gridView.DataBind(); } } }
protected void Page_Load(object sender, EventArgs e) { if (!long.TryParse(this.Page.Request.QueryString["VoteId"], out this.voteId)) { base.GotoResourceNotFound(); } else { this.btnEditVote.Click += new EventHandler(this.btnEditVote_Click); if (!this.Page.IsPostBack) { VoteInfo voteById = SubsiteStoreHelper.GetVoteById(this.voteId); IList <VoteItemInfo> voteItems = SubsiteStoreHelper.GetVoteItems(this.voteId); if (voteById == null) { base.GotoResourceNotFound(); } else { this.txtAddVoteName.Text = Globals.HtmlDecode(voteById.VoteName); this.checkIsBackup.Checked = voteById.IsBackup; this.txtMaxCheck.Text = voteById.MaxCheck.ToString(); string str = ""; foreach (VoteItemInfo info2 in voteItems) { str = str + Globals.HtmlDecode(info2.VoteItemName) + "\r\n"; } this.txtValues.Text = str; } } } }
protected void Page_Load(object sender, System.EventArgs e) { if (!long.TryParse(this.Page.Request.QueryString["VoteId"], out this.voteId)) { base.GotoResourceNotFound(); return; } this.btnEditVote.Click += new System.EventHandler(this.btnEditVote_Click); if (!this.Page.IsPostBack) { VoteInfo voteById = SubsiteStoreHelper.GetVoteById(this.voteId); System.Collections.Generic.IList <VoteItemInfo> voteItems = SubsiteStoreHelper.GetVoteItems(this.voteId); if (voteById == null) { base.GotoResourceNotFound(); return; } this.txtAddVoteName.Text = Globals.HtmlDecode(voteById.VoteName); this.checkIsBackup.Checked = voteById.IsBackup; this.txtMaxCheck.Text = voteById.MaxCheck.ToString(); string text = ""; foreach (VoteItemInfo current in voteItems) { text = text + Globals.HtmlDecode(current.VoteItemName) + "\r\n"; } this.txtValues.Text = text; } }