Display a report links listing in dataview ASP.NET using C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • AlDave
    New Member
    • Jul 2008
    • 1

    Display a report links listing in dataview ASP.NET using C#

    What I'm trying display is after the user chooses the product (1st category) from a dropdown, then the dataview will display;

    The category

    any reports under that

    subcategory

    any reports under that

    any other sub categories involved with the product first category

    All I'm able to get so far is after choosing from the drop down, the categories 1st layer. I'm not sure how to code to get the reports under each category and the code to do so.
    I am working on web page that display reports from an XML file so the user can click a link and open a report. The problem I'm having is I able to get to the first catagory but do not know how to code to get to the report attribute. The following is the short version of the XML file;
    Code:
     
    <?xml version="1.0" standalone="yes"?> 
    <CommercialCardReports xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
     
    <CommercialCardReportCategory CategoryId="665" Name="Gray Data Feeds"/> 
    <CommercialCardReportCategory CategoryId="1" Name="Canada">
     
    <CommercialCardReport ReportId="881" Name="CAN-THD0010 - THD Naps Error Letters" HasArchiveFlag="true" Directory="D:/reports/CAN-THD0010" FileName="naps_errors.xls"/> 
    <CommercialCardReportCategory CategoryId="2" Name="HDCS">
     
    <CommercialCardReportCategory CategoryId="3" Name="External Status Change Reports"> 
    <CommercialCardReport ReportId="4" Name="CAN-CRD0880A - Canada" HasArchiveFlag="true" Directory="D:/reports/CAN-CRD0880A" FileName="Canada_THDCRCStatusChange.xls"/>
     
    </CommercialCardReportCategory> 
    </CommercialCardReportCategory>
     
    <CommercialCardReportCategory CategoryId="663" Name="PROX Reports"> 
    <CommercialCardReport ReportId="807" Name="CAN-PRD70246 - THD PROX Canada Inquires" HasArchiveFlag="true" Directory="D:/reports/CAN-PRD70246" FileName="thdcanada_inq.xls"/>
     
    </CommercialCardReportCategory> 
    <CommercialCardReportCategory CategoryId="21" Name="RPL">
     
    </CommercialCardReportCategory> 
    </CommercialCardReportCategory>
     
    </CommercialCardReports>
     
    The following what I have in the aspx page;
     
    <asp:XmlDataSource ID="XmlDataSource1" runat="server" DataFile="~/App_Data/Reports.xml"
    XPath="/CommercialCardReports/CommercialCardReportCategory">
    </asp:XmlDataSource>
     
    <asp:DropDownList ID="productDropDownList" runat="server" 
    AppendDataBoundItems="True" AutoPostBack="True" DataSourceID="XmlDataSource1" 
     
    DataTextField="Name" DataValueField="CategoryId" 
    onselectedindexchanged="productDropDownList_SelectedIndexChanged">
    <asp:ListItem Selected="True">--Select Product--</asp:ListItem>
    </asp:DropDownList>
     
    <asp:DataList ID="DataList1" runat="server" DataSourceID="XmlDataSource2" 
    Visible="False" BorderStyle="Solid" BorderWidth="2px">
    <ItemTemplate>
    <asp:Label ID="categoryId" Visible="false" runat="server" Text='<%# Eval("CategoryId") %>'></asp:Label><br />
    <asp:Label ID="name" runat="server" Text='<%# Eval("Name") %>'></asp:Label><br />
    </ItemTemplate>
    </asp:DataList><br />
     
    <asp:XmlDataSource ID="XmlDataSource2" runat="server" DataFile="~/App_Data/Reports.xml"
    XPath="/CommercialCardReports/CommercialCardReportCategory/CommercialCardReportCategory">
    </asp:XmlDataSource>
    And this what I have in the code behind;
    Code:
     
    protected void productDropDownList_SelectedIndexChanged(object sender, EventArgs e) 
    {
    String CategoryId = (String)productDropDownList.SelectedItem.Value; 
    XmlDataSource2.XPath = String.Format("/CommercialCardReports/CommercialCardReportCategory[@CategoryId='{0}']/CommercialCardReportCategory", CategoryId);
    DataList1.Visible = true; 
    }
    I would appreciate any help I can get thank you.........
    Last edited by DrBunchman; Jul 21 '08, 03:14 PM. Reason: Added [Code] Tags - Please use the '#' button
Working...