Link to home
Start Free TrialLog in
Avatar of ukinet
ukinet

asked on

Load Xml Data in Nested Gridview

Hi,

I have a nested Gridview (a Gridview within a Gridview), which is from a customers table.  The main Gridview lists the customer's name and the nested Gridview is to list the related products for the customer, which is stored as xml within the database table.  The code takes the following form (formatting, etc. removed):

<asp:GridView id="Customers" runat="server">
  <Columns>
    <asp:TemplateField>
      <ItemTemplate>
        <table>
          <tr>
            <td>
              <asp:Label id="Customer" runat="server"><%# DataBinder.Eval(((GridViewRow)Container).DataItem, "Customer") %></asp:Label>
            </td>
          </tr>
          <tr>
            <td>
              <asp:XmlDataSource id="xxmlData" runat="server" EnableCaching="false"></asp:XmlDataSource>
              <asp:GridView id="Products" runat="server">
                <Columns>
                  <asp:TemplateField>
                    <ItemTemplate>
                      <table>
                        <tr>
                          <td>
                            <asp:Label id="Product" runat="server"><%# XPath("Product") %></asp:Label>
                          </td>
                          <td>
                            <asp:ImageButton id="ProductLink" runat="server" CommandName='<%# XPath("ProductID") %>' OnClick="View" />
                          </td>
                        </tr>
                      </table>
                    </ItemTemplate>
                  </asp:TemplateField>
                </Columns>
              </asp:GridView>
            </td>
          </tr>
        </table>
      </ItemTemplate>
    </asp:TemplateField>
  </Columns>
</asp:GridView>

Does anyone know how I can load the Xml data into the nested Gridview via the XmlDataSource?

Thanks,

John
ASKER CERTIFIED SOLUTION
Avatar of MogalManic
MogalManic
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial