private void PopulateControls() { int userId = Convert.ToInt32(Session["UserID"]); DateTime today = Convert.ToDateTime(Session["TodayDate"]); MonthBLL bll = new MonthBLL(); DataTable dt = bll.GetFenLeiZongJiList(userId, today); string value = ""; if (dt.Rows.Count > 0 && Convert.ToDouble(dt.Rows[0]["ZhiPriceTotal"]) > 0) { foreach (DataRow dr in dt.Rows) { if (Convert.ToDouble(dr["ZhiPriceTotal"]) > 0) { value += "{\"value\":" + dr["ZhiPriceTotal"].ToString() + ",\"label\":\"" + dr["CategoryTypeName"].ToString() + "\",\"text\":\"" + dr["CategoryTypeName"].ToString() + "\"},"; } } value = value.Remove(value.Length - 1); } else { value = "{\"value\":100,\"label\":\"空记录\",\"text\":\"空记录\"}"; } Response.Write(GetChartJsonString(value)); Response.End(); }
//初始数据 private void PopulateControls() { DataTable lists = bll.GetFenLeiZongJiList(userId, today); List.DataSource = lists; List.DataBind(); double zhiPriceTotal = 0d; double shouPriceTotal = 0d; foreach (DataRow dr in lists.Rows) { zhiPriceTotal += Convert.ToDouble(dr["ZhiPriceTotal"]); shouPriceTotal += Convert.ToDouble(dr["ShouPriceTotal"]); } this.Label3.Text = zhiPriceTotal.ToString("0.0##"); this.Label2.Text = shouPriceTotal.ToString("0.0##"); this.hidChartData.Value = ItemHelper.GetChartData(lists, "PageUrl"); }