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">
</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;"
/> <asp:ImageButton ID="ImageButton7" runat="server" ImageUrl="~/images/Edit.png"
/> <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> </td>
</tr>
<tr style="background-color: #95b3d7">
<td colspan="3">
Link
<input id="radLink" type="radio"
name="choosebox" /></td>
</tr>
<tr style="background-color: #c6d9f1">
<td colspan="3">
Popup
<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
|