2011-06-20 5 views
1

私は、次のデータセットがあります。私は次のコードを使用してチャートにこれを表示しようとしていますヘルプ

NAME | GP | ORD_GP | EXP | TOTAL GP | TARGET 
a  206  48  -239  15   1600 
b  0  27  0  27  1520 

は、私が表示したいすべてがNAME TOTAL_GPTARGET次のとおりです。

Chart1.Width=600; 
    Chart1.BackColor = Color.Gray; 
    Chart1.BackSecondaryColor = Color.WhiteSmoke; 
    Chart1.BackGradientStyle = GradientStyle.DiagonalRight; 
    Chart1.BorderlineDashStyle = ChartDashStyle.Solid; 
    Chart1.BorderlineColor = Color.Gray; 
    Chart1.BorderSkin.SkinStyle = BorderSkinStyle.Emboss; 

    // format the chart area 
    Chart1.ChartAreas[0].BackColor = Color.Wheat; 
    // add and format the title 
    Chart1.Titles.Add("ASP.NET Chart"); 
    Chart1.Titles[0].Font = new Font("Utopia", 16); 

    // clear the chart series and bind to the table 
    Chart1.DataSource = ds.Tables[0]; 
    Chart1.Series[0].XValueMember = "NAME"; 
    Chart1.Series[0].YValueMembers = "TOTAL_GP"; 

    Chart1.Series[0].ChartType = SeriesChartType.StackedBar; 

エラーが発生します。私が間違っていることをアドバイスできますか?以下のようにエラーがある

Exception Details: System.ArgumentOutOfRangeException: Index was out of range. 
Must be non-negative and less than the size of the collection. 
parameter name: index 

UPDATE

私は

<asp:Chart ID="Chart1" runat="server"> 
     <ChartAreas> 
      <asp:ChartArea Name="ChartArea1" /> 
     </ChartAreas> 
    </asp:Chart> 
+0

どのラインでエラーが表示されますか? – CResults

+0

Chart1.Series [0] .XValueMember = "NAME"; – c11ada

答えて

0

は、それを解決し

<asp:Chart ID="Chart1" runat="server"> 
    <Series> 
     <asp:Series Name="Series1"> 
     </asp:Series> 
    </Series> 
    <ChartAreas> 
     <asp:ChartArea Name="ChartArea1"> 
     </asp:ChartArea> 
    </ChartAreas> 
</asp:Chart> 
への.aspxファイルを変更しなければならなかった私の.aspxのファイルに次の持っています