下拉选择的值应该在dotnetcharting明细中显示所需的数据 [英] Dropdown selected value should show the required data in dotnetcharting drilldown
本文介绍了下拉选择的值应该在dotnetcharting明细中显示所需的数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我正在使用dotnetCharting Drildown并且从下拉列表中选择年份,所选年份的详细信息应该出现在我的图表上。
我尝试过:
Hi
I am working on dotnetCharting Drildown and wile choosing year from the dropdown the selected year details should come on my chart.
What I have tried:
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Drawing;
using System.Drawing.Drawing2D;
using dotnetCHARTING;
using System.Configuration;
using System.Data.SqlClient;
namespace dotnetdrilldown03
{
public partial class DrillDropdown : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
Chart.DefaultSeries.ConnectionString = ConfigurationManager.ConnectionStrings["sqlconnection"].ConnectionString;
if (!IsPostBack)
{
Bindddl();
}
Chart.YAxis.Label.Text = "No of Students";
Chart.Title = "Progress Report";
Chart.XAxis.Label.Text = "Years";
Chart.Width = 750;
Chart.Height = 550;
Chart.Debug = true;
Chart.DateGrouping = TimeInterval.Years;
Chart.DrillDownChain = "Years,Quarters,Months,Full";
Chart.DefaultSeries.DefaultElement.ToolTip = "%yvalue";
Chart.Series.Name = "Bonus points";
Chart.Series.StartDate = new System.DateTime(2014, 1, 1, 0, 0, 0);
Chart.Series.EndDate = new System.DateTime(2017, 12, 31, 23, 59, 59);
Chart.Series.SqlStatement = @"SELECT Duration,Total FROM Report WHERE Duration >= #STARTDATE# ";
Chart.SeriesCollection.Add();
}
protected void Bindddl()
{
Ddldrill.Items.Add("2014");
Ddldrill.Items.Add("2015");
Ddldrill.Items.Add("2016");
Ddldrill.Items.Add("2017");
if (Request.QueryString["limitMode"] != null)
Ddldrill.SelectedIndex = (int)Enum.Parse(typeof(dotnetCHARTING.LimitMode), Request.QueryString["limitMode"], true);
Chart.Series.LimitMode = (dotnetCHARTING.LimitMode)Enum.Parse(typeof(dotnetCHARTING.LimitMode), Ddldrill.SelectedItem.Value, true);
Ddldrill.DataBind();
Ddldrill.Items.Insert(0, new ListItem("--Select--"));
if (Ddldrill.SelectedItem.Value = "")
{
}
}
protected void Ddldrill_SelectedIndexChanged(object sender, EventArgs e)
{
Bindddl();
}
dotnetCHARTING.SeriesCollection Calculate()
{
dotnetCHARTING.SeriesCollection SC = new dotnetCHARTING.SeriesCollection();
Random myR = new Random(1);
for (int a = 0; a < 4; a++)
{
dotnetCHARTING.Series s = new dotnetCHARTING.Series();
s.Name = "Series " + a.ToString();
for (int b = 0; b < 1; b++)
{
Element e = new Element();
e.Name = "Element " + b.ToString();
e.YValue = myR.Next(20);
s.Elements.Add(e);
}
SC.Add(s);
}
SC[0].Element.Color = Color.FromArgb(49, 255, 49);
SC[0].Elements[0].Name = "English";
SC[0].LegendEntry.Value = "13";
SC[0].LegendEntry.Name = "Between 10-15";
return SC;
}
}
}
推荐答案
ASP.NET在页面中都有代码和代码隐藏。您缺少帮助解决问题的重要部分 - .ASPX页面。你的问题不是描述症状 - 例如:我的车不会启动。转动钥匙时会发生什么?我听到了噪音?什么声音?等等...没有细节,这是任何人的猜测!
现在,我是一个MVC开发人员,而不是Asp.Net WebPage dev,所以它花了我一些调整的时刻。所以,这是我在暗中猜测:我认为你丢失DropDownList上的属性:
ASP.NET has both code in the page and a code-behind. You are missing an important part to help resolve your issue - the .ASPX page. You question is not describing the symptoms - eg: my car won't start. What happens when you turn the key? I hear a noise? what noise? etc... Without details, it is anyone's guess!
Now, I am a MVC dev, not a Asp.Net WebPage dev, so it took me a few moments to adjust. So, here is my stab-in-the-dark guess: I think that you are missing a property on your DropDownList:
AutoPostBack="True"
导致DropDownList在代码隐藏中选择的事件不会触发。
为了演示我想你想要的DropDownList,这是一个有效的例子:
1.页面:
causing the DropDownList selected event in the code-behind to not fire.
To demonstrate the DropDownList peforming as I think you want it to, here is a working example:
1. Page:
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="col-md-4">
<h2>DropDown Test</h2>
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged"></asp:DropDownList>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</div>
</asp:Content>
2。代码隐藏
using System;
using System.Collections.Generic;
using System.Web.UI;
namespace WebApplication1
{
public partial class _Default : Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitData();
}
}
public List<string> Options { get; set; }
private void InitData()
{
Options = new List<string> { "AAA", "BBB", "CCC" };
foreach (var item in Options)
{
DropDownList1.Items.Add(item);
}
DropDownList1.SelectedIndex = 0;
SetLabel();
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
SetLabel();
}
private void SetLabel()
{
Label1.Text = DropDownList1.SelectedItem.Text;
}
}
}
这篇关于下拉选择的值应该在dotnetcharting明细中显示所需的数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文