Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XML
| Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 15th, 2007, 07:38 AM
Authorized User
 
Join Date: Nov 2007
Location: Allahabad, UP, India.
Posts: 33
Thanks: 0
Thanked 0 Times in 0 Posts
Default How to dispaly attributes of xml nested repeater..

Hello every one I am facing a problem to display attribute of parent node and corresponding child

nodes.Suppose I have to display Label attributes of all <ScreenToSupport>. There can be multiple

<ScreenToSupport> inside parent node <ScreensToSupport>.
In this case I have to display Label 'rediffHomePage' and 'rediffHomePage1' of both

<ScreenToSupport> node. There is no issue to diplay these two Label. I done this by taking a

repeater control.
But problem arrises when I have to display corresponding Label of 'FieldsToSupport/FieldToSupport'

of <ScreenToSupport>..
For example on click an Item like rediffHomePage from a repeater It should display like 'HotJobs'

and 'Game'. How can I display Label of corresponding FieldsToSupport/FieldToSupport on click on

corresponding Label of <ScreenToSupport>.. Should I take Repeater inside Repeater or I Repeater

inside DataList.

following is the structure of XML file
--------------------------------------------------------------------
  <ScreensToSupport>
    <ScreenToSupport>
      <ScreenUniqueId>199d1dfd-63ca-4271-b234-77da0f579e0e</ScreenUniqueId>
      <SupportItems>
        <ScreenSupportItem>
          ...
    <RefId>1</RefId>
        </ScreenSupportItem>
      </SupportItems>
      <FieldsToSupport>
        <FieldToSupport>
          ...
          <Label>HotJobs</Label>
          ...
          <FieldSupportItems />
        </FieldToSupport>
        <FieldToSupport>
          ...
          <Label>Game</Label>
          ...
          <FieldSupportItems />
        </FieldToSupport>
      </FieldsToSupport>
      <Label>rediffHomePage</Label>

</ScreenToSupport>
    <ScreenToSupport>
      <ScreenUniqueId>e62abc49-efc7-4a5d-908f-33f2f4df070b</ScreenUniqueId>
      <SupportItems>
        <ScreenSupportItem>
          ...
    <RefId>2</RefId>
        </ScreenSupportItem>
      </SupportItems>
      <FieldsToSupport>
        <FieldToSupport>
          ..
          <Label>Images</Label>
          ..
          <FieldSupportItems />
        </FieldToSupport>
        <FieldToSupport>
          ...
          <Label>Air Tickets</Label>
          ...
          <FieldSupportItems />
        </FieldToSupport>
      </FieldsToSupport>
      <Label>rediffHomePage1</Label>
    </ScreenToSupport>
  </ScreensToSupport>
--------------------------------------------------------------------
and following is my .cs file
--------------------------------------------------------------------
<%@ Page Language="C#" MasterPageFile="~/BaydonHeader.master" AutoEventWireup="true"

CodeFile="list_labels.aspx.cs" Inherits="list_labels" %>
<%@ Import Namespace="System.Xml" %>
<%@ Import Namespace="System.Data"%>
<%@ Import Namespace="Baydon"%>
<%@ Import Namespace="System.Data.SqlClient"%>
<asp:Content ID="Content2" ContentPlaceHolderID="cphDetail" runat="Server">
<script runat="server">

 public void Page_Load(Object sender, EventArgs e){
        string AlbumPath = Request.QueryString["AlbumPath"];
        string AlbumName = Request.QueryString["AlbumName"];
        string path=AlbumPath + "/" + AlbumName + ".linkinfo.xml";
        XmlDataSource1.DataFile = path;
       // XmlDataSource2.DataFile = path;

        XmlDataSource2.Data = "<FieldsToSupport><FieldToSupport><Label>Just To Test

1</Label></FieldToSupport><FieldToSupport><Label>Just To Test

2</Label></FieldToSupport></FieldsToSupport>";

        if (!IsPostBack) {
            string xmlFilePath = @path;
            UpdateXml();
            //XmlDocument doc = new XmlDocument();
            //doc.Load(xmlFilePath);
            System.Data.DataSet objDataSet = new DataSet();
            objDataSet.ReadXml(path);
        }
    }

    public void UpdateXml()
    {
        try
        {

                string AlbumPath = Request.QueryString["AlbumPath"];
                string AlbumName = Request.QueryString["AlbumName"];
                string path = AlbumPath + "\\" + AlbumName + ".linkinfo.xml";
                XmlDocument doc = new XmlDocument();
                doc.Load(path);
                System.Data.DataSet objDataSet = new DataSet();
                objDataSet.ReadXml(path);

                int intRefId = 1; //Request.QueryString["RefId"].ToString();

            /*ls*/
                string strXPathLS =

"/LinkInformation/ScreensToSupport/ScreenToSupport/SupportItems/ScreenSupportItem[RefId='" +

intRefId + "']";
                XmlNode newParentLS = doc.SelectSingleNode(strXPathLS).ParentNode.NextSi bling;

                /*
                Repeater repeaterLS = new Repeater();
                repeaterLS=(Repeater)Repeater1.FindControl("Repeat er2");
                Repeater3.DataSource = newParentLS;
                Repeater3.DataBind();
                */

                /*
                foreach (System.Xml.XmlNode node1LS in newParentLS)
                {
                    Response.Write(node1LS["Label"].InnerText + "<br>");
                }
                */
            /*ls*/
        }
        catch (Exception err)
        {
            Response.Write(err);
            //lblError.Text = "ERROR:" + err.Message.ToString();
            //txtUrlTitle.Focus();
        }

    }

</script>

<script type="text/javascript">

function showCD(str)
{
// var strXML=document.getElementById("scid").value;
// alert(strXML);
var imgId=str;

function getURLParam(strParamName){

var strPath = "";
var strName = "";
  var strHref = window.location.href;
  if ( strHref.indexOf("?") > -1 ){
    var strQueryString = strHref.substr(strHref.indexOf("?")).toLowerCase() ;
    var aQueryString = strQueryString.split("&");
    strPath = aQueryString[0];
    strName = aQueryString[1];
    var url="list_labels.aspx"+strPath+"&"+strName+"&ImgId ="+imgId;
    window.location=url;
  }
}
getURLParam("AlbumPath");

}
</script>
<div align="center">
 <fieldset class="fieldset1" style="border-bottom-color:#6699ff;

border-left-color:#6699ff;border-right-color:#6699ff; border-top-color:#6699ff;

border-style:groove;">

         <table style="width: 100%; height: 100%">

            <tr>
                <td align="left" style="width: 19%; height: 100%" valign="top">

                    <table style="border-right: #6699ff thin solid; border-top: #6699ff thin solid;

padding-left: 4px;
                        border-left: #6699ff thin solid; width: 87%; border-bottom: #6699ff thin

solid;
                        height: 90%">
                        <tr>
                            <td align="left" style="width: 216px; height: 100px" valign="top">
                                <table style="height: 40%">
                                    <tr>
                                        <td style="height: 18px; background-color: #0099cc;"

valign="top">

                                            <asp:Label ID="Label4" runat="server" ForeColor="Black"

Text="Labels" BackColor="Transparent" Font-Bold="True" Font-Size="Medium" Width="216px"></asp:Label>
                                            </td>
                                    </tr>

                                     <tr>
                                        <td style="height: 175px" valign="top">
                                            <asp:XmlDataSource runat="server" id="XmlDataSource1"

XPath="LinkInformation/ScreensToSupport" />
                                            <asp:XmlDataSource runat="server" id="XmlDataSource2"

XPath="FieldsToSupport" />

                                            <asp:Repeater ID="Repeater1" runat="server"

DataSourceID="XmlDataSource1">
                                                <ItemTemplate>
                                                    <asp:Repeater ID="Repeater2"

DataSource='<%#XPathSelect("ScreenToSupport")%>' runat="server">


                                                        <ItemTemplate>
                                                        <%--<a href="#"

onclick="showCustomer(<%#XPath(SupportItems/ScreenSupportItem/RefId)%>)"><b><%#XPath("Label")%></b><

/a>--%>
                                                            <input type="button"

onclick="showCD(<%#XPath("SupportItems/ScreenSupportItem/RefId")%>)" value="<%#XPath("Label")%>"

style="border-right: #66ffff thin ridge; border-top: #66ffff thin ridge; font-weight: bold;

font-size: 12px; vertical-align: middle; text-transform: capitalize; border-left: #66ffff thin

ridge; cursor: hand; color: Black; border-bottom: #66ffff thin ridge; font-family: Verdana;

background-color: #E2EBED; text-align: left;width:100%" />
                             <asp:Repeater ID="Repeater3" runat="server"

DataSourceID="XmlDataSource2">
                                  <ItemTemplate>
<asp:Repeater ID="Repeater9" DataSource='<%#XPathSelect("FieldToSupport")%>' runat="server">


<ItemTemplate>
                                                 <%#XPath("Label")%> <br />
</ItemTemplate>
</asp:Repeater>
                                   </ItemTemplate>
                             </asp:Repeater>
                                                        </ItemTemplate>
                                                    </asp:Repeater>
                                                </ItemTemplate>
                                            </asp:Repeater>
                                            </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>

                    <table style="border-right: #6699ff thin solid; padding-left: 4px; border-left:

#6699ff thin solid; width: 100%; border-bottom: #6699ff thin solid; height: 90%">
                        <tr>
                            <td style="width: 218px" valign="top">
                                <table style="height: 30%">
                                    <tr>
                                        <td valign="top" style="width: 264px">
                                            <asp:Label ID="Label7" runat="server" ForeColor="Black"

Text="Actions"></asp:Label></td>
                                    </tr>
                                    <tr>
                                        <td valign="top" style="width: 264px; height: 18px">
                                            &nbsp; &nbsp;&nbsp;
                                            </td>
                                    </tr>
                                    <tr>
                                        <td align="left" valign="middle" style="width: 264px">
                                            <asp:ImageButton ID="ImageButton2" runat="server"

ImageUrl="~/images/new.png"

OnClientClick="document.getElementById('helptypedi v').style.visibility='visible';return false;"

/>&nbsp;<asp:ImageButton ID="ImageButton7" runat="server" ImageUrl="~/images/Edit.png"

/>&nbsp;<asp:ImageButton ID="ImageButton8" runat="server" ImageUrl="~/images/Delete.png" /></td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                    </table>
                </td>
                <td style="width: 75%" valign="top">
                    <table border="0" cellpadding="0" cellspacing="0" style="border-right: #6699ff

thin solid; border-top: #6699ff thin solid; padding-left: 4px; border-left: #6699ff thin solid;

width: 50%; border-bottom: #6699ff thin solid; height: 50%">
                        <tr>
                            <td colspan="2" style="height: 23px">
                                <asp:ImageButton ID="ImageButton1" runat="server"

ImageUrl="~/images/Page-View-hover.png" />
                                <asp:ImageButton ID="ImageButton6" runat="server"

ImageUrl="~/images/Browser-View.png" /></td>
                        </tr>

                        <tr style="color: #000000">
                            <td align="left" colspan="2" style="width: 50%; height: 40%;

background-color: #ffffff">

                                <div style="border-right: green 1px solid; border-top: green 1px

solid; z-index: 1; left: 400px; visibility: hidden; border-left: green 1px solid; width: 200px;

border-bottom: green 1px solid;position: absolute; top: 250px; background-color: #e2ebed"

id="helptypediv">
                                    <table style="height: 100%; width: 100%;">
                                            <tr style="background-color: #365f91">
                                                <td align="center" colspan="3">
                                                    <asp:Label ID="Label1" runat="server"

ForeColor="White" Text="Select Action"></asp:Label>&nbsp;</td>

     </tr>
                                            <tr style="background-color: #95b3d7">
                                                <td colspan="3">
                                                    Link&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                                    <input id="radLink" type="radio"

name="choosebox" /></td>
                                            </tr>
                                            <tr style="background-color: #c6d9f1">
                                                <td colspan="3">
                                                    Popup&nbsp;&nbsp;
                                                    <input id="radPopup" type="radio"

name="choosebox" /></td>
                                            </tr>
                                            <tr>
                                                <td colspan="3">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="center" colspan="3">
                                                    <input id="Button2" type="button" value=" Ok "

/>
                                                    <input id="Button1"

onclick="document.getElementById('helptypediv').st yle.visibility='hidden'" type="button"

value="Cancel" />
                                                </td>
                                            </tr>
                                    </table>
                                 </div>
                                  <div style="width: 700px; height: 400px; overflow: auto;

font-family: Verdana, Tahoma, Helvetica, sans-serif; font-size: 11px; color: #000000;">
                                      <asp:Image ID="Image1" runat="server" /></div>
                            </td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
    </fieldset>
   </div>
</asp:Content>
--------------------------------------------------------------------
I am not very familiar with how displaying XML contents.. I tried this way..
But stuck on that point please help me ..
I will very thankful for that..

Vishnu


Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem with binding XMl data into nested repeater vishnu108mishra XML 0 November 19th, 2007 03:53 AM
nested repeater ramonjor ASP.NET 2.0 Basics 0 July 31st, 2007 04:18 AM
FindControl in nested repeater chrisk_47 .NET Framework 2.0 0 February 6th, 2007 10:45 PM
transformation from attributes to nested elements e-bell XSLT 2 January 21st, 2007 07:21 PM
nested repeater david_ste ASP.NET 2.0 Professional 0 August 24th, 2006 09:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.