图表信息取决于每个数据网格行

时间:2011-05-23 17:17:51

标签: asp.net datagrid row charts

我希望在数据网格的每一行上都有一个图表,因为图表源信息是图表插入行的信息。

这是我到目前为止所得到的:

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" 
            DataKeyNames="idCampaign" DataSourceID="SqlDataSource1" >
   <Columns>
      <asp:BoundField DataField="idPerson" HeaderText="idPerson" Visible="false"
                    InsertVisible="False" ReadOnly="True" SortExpression="idPerson" />
      <asp:BoundField DataField="name" HeaderText="name" SortExpression="name" />
      <asp:BoundField DataField="age" HeaderText="age" SortExpression="age" />   
      <asp:TemplateField>
         <ItemTemplate>
            <asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource2">
               <Series>
                  <asp:Series Name="Series1" XValueMember="name" 
                                    YValueMembers="age"></asp:Series>
                  </Series>
                  <ChartAreas>
                     <asp:ChartArea Name="ChartArea1"></asp:ChartArea>
                  </ChartAreas>
            </asp:Chart>
              <asp:SqlDataSource ID="SqlDataSource3" runat="server" 
                            ConnectionString="<%$ ConnectionStrings:outboundsmsConnectionString %>"
                            SelectCommand="SELECT idPerson, name, age FROM Person WHERE (idPerson = **currentRowPersonId**)">
                        </asp:SqlDataSource>
                    </ItemTemplate>
                </asp:TemplateField>
                           </Columns>
        </asp:GridView>

我在这方面遇到了一些麻烦,并且不知道如何获得大胆的部分......

任何帮助?

2 个答案:

答案 0 :(得分:1)

乍得的消化有所作为,但有点扭曲:

SelectCommand='<%# Eval("idPerson", "SELECT idPerson, name, age FROM Person WHERE (idPerson = {0}") %>)'

谢谢!

答案 1 :(得分:0)

SelectCommand='SELECT idPerson, name, age FROM Person WHERE (idPerson = <%# Eval("idPerson") %>)'