Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/30.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET图表自定义标签从总时间以秒为单位显示HH:MM:SS_C#_Asp.net_.net_Charts_Mschart - Fatal编程技术网

C# ASP.NET图表自定义标签从总时间以秒为单位显示HH:MM:SS

C# ASP.NET图表自定义标签从总时间以秒为单位显示HH:MM:SS,c#,asp.net,.net,charts,mschart,C#,Asp.net,.net,Charts,Mschart,我需要在图表中添加一个自定义标签,以在asp.net中显示HH:MM:SS来自sql server的时间以秒为单位,图表的填充方式如下: SqlConnection con = new SqlConnection(easystone); SqlDataAdapter graph = new SqlDataAdapter("SELECT [User], sum([Total Time]) as [total time] ,[week] FROM [Toolpaths].[dbo]

我需要在图表中添加一个自定义标签,以在asp.net中显示HH:MM:SS来自sql server的时间以秒为单位,图表的填充方式如下:

    SqlConnection con = new SqlConnection(easystone);
    SqlDataAdapter graph = new SqlDataAdapter("SELECT [User], sum([Total Time]) as [total time]  ,[week] FROM [Toolpaths].[dbo].[totaltimeuser] where [week] like '" + DropDownList2.Text + "' group by [user], [week] order by 'total time' desc", con);
    DataTable graphdata = new DataTable();
    graph.Fill(graphdata);
    chart1.DataSource = graphdata;


    chart1.ChartAreas["ChartArea1"].AxisX.Title = "";

    chart1.Series["Series1"].XValueMember = "User";
    chart1.Series["Series1"].YValueMembers = "total time";
    year.Text = DropDownList2.Text;
试试这个:

    protected void Page_Load(object sender, EventArgs e)
    {
        foreach (DataRow row in graphdata.Rows)
        {
            int total = (int)row["total time"];
            int index = chart1.Series[0].Points.AddXY(row["User"], new object[] { total });

            chart1.Series[0].Points[index].Label = string.Format("{0:00}:{1:00}:{2:00}", (total / 60) / 60, (total / 60) % 60, total % 60);
        }
    }