2015-06-23 63 views
2
public void bindChartDetail() 
{ 

    objUser = (UserEntity)Session["User"]; 



    if (objUser == null) 
    { 
     Response.Redirect("~/Default.aspx"); 
    } 
    DateTime fromDate; 
    DateTime toDate; 
    String strDomainName = ""; 


    if (ddlDomainName.SelectedIndex > 0) 
    { 
     strDomainName = ddlDomainName.SelectedItem.Text.ToString(); 

    } 
    else 
    { 
     strDomainName = lblDomainName.Text; 

    } 
    if (txtFromDate.Text != "") 
    { 
     fromDate = DateTime.ParseExact(txtFromDate.Text, "dd-MM-yyyy", null); 
    } 

    else 
    { 
     fromDate = toDate = System.DateTime.Now; 
    } 

    if (txtToDate.Text != "") 
    { 

     toDate = DateTime.ParseExact(txtToDate.Text, "dd-MM-yyyy", null); 
    } 

    else 
    { 
     toDate = System.DateTime.Now; 
    } 


    ReportBL objReport = new ReportBL(); 
    PagedDataSource rptPager = null; 
    DataTable dt = null; 
    try 
    { 
     dt = new DataTable(); 

     dt = objReport.USERWISEACCOUNTINGINFORMATIONWITHINBOUNDOUTBOUND(strDomainName, 0, fromDate, toDate); 
     if (dt == null) 
     { 
      if (dt.Rows.Count > 0) 
      { 
       byte[] YPointMember = new byte[dt.Rows.Count]; 
       ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss"; 
       //DateTime[] YPointMember = new DateTime[dt.Rows.Count]; 
       for (int count = 0; count < dt.Rows.Count; count++) 
       { 
        YPointMember[count] = Convert.ToByte(dt.Rows[count]["INBOUND"]); 
        //YPointMember[count] = (dt.Rows[count]["connectdatetime"]); 
       } 
       Chart1.Series[0].Points.DataBindXY(YPointMember); 
       Chart1.Series[0].BorderWidth = 1; 
       Chart1.Series[0].ChartType = SeriesChartType.Line; 
      } 

我的數據庫中有兩個字段:inbounddate。我想以24小時格式在x軸上顯示date,但我不知道,因爲我是圖表控制的新手。如何在ms圖表中以24小時格式綁定日期

回答

0

你可以試試這個

ChartAreas[0].AxisX.LabelStyle.Format = "HH:mm:ss.fff"; 
+0

我使用它,但是我showning錯誤-chart區不存在。以及如何把我的細節留下。 –

+0

有點小費!如果秒數不顯示,請使用#VALY {HH:mm:ss}等關鍵字。 –

相關問題