XmlDataSource or DataSetDataSource

R

rote

I have a code below i'm trying to test
It had a DataSetDatasource but i thinks its deprecated if yes what can i use
in this scenario below?
I used XmlDatasource but its saying it can't find the property url in the
xml which is there

Any ideas?
** XML datasource file below




<asp:XmlDataSource ID="DataSetDataSource1" Runat="server"
DataFile="~/data/Announcements.xml"/>

<asp:DataList ID="DataList1" Runat="server"
DataSourceID="DataSetDataSource1">

<ItemTemplate>

<table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0">

<tr>

<td valign="top" style="width: 80%">

<asp:HyperLink ID="TitleLabel" Runat="server" NavigateUrl='<%#
DataBinder.Eval(Container.DataItem, "url") %>'

Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>'
Font-Names="verdana"

Font-Bold="True" Font-Size="8pt" ForeColor="#003399" />

<br />

by

<asp:Label ID="OwnerLabel" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Owner") %>'

ForeColor="#003399" />

</td>

<td style="text-align: right" align="right" valign="top">

<asp:Label ID="DateLabel" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Date") %>'

Font-Names="verdana" Font-Bold="True" Font-Size="8pt" ForeColor="#003399" />

</td>

</tr>


<tr>

<td colspan="2">

<asp:Label ID="DescriptionLabel" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Description") %>' />

</td>

</tr>

</table>

</ItemTemplate>

</asp:DataList>

----------------------------------------------

<?xml version="1.0" encoding="utf-8" ?>

<announcements>

<announcement>

<id>1</id>

<title>New Intranet Portal Launched!</title>

<date>6/1/2003</date>

<owner>Star Developer</owner>

<description>Our new Company Intranet Portal has launched! Be sure to check
out the ultra cool personalization abilities.</description>

<url>~/sales.aspx</url>

</announcement>

<announcement>

<id>2</id>

<title>Top Customers Identified</title>

<date>6/1/2003</date>

<owner>Sales Manager</owner>

<description>We have identified our top customers based on orders placed.
Check out the Sales tab for more details.</description>

<url>~/default.aspx</url>

</announcement>

<announcement>

<id>3</id>

<title>Pay Day</title>

<date>5/15/2003</date>

<owner>President</owner>

<description>We have decided to double eveyone's paycheck this month.
Enjoy!</description>

<url>~/default.aspx</url>

</announcement>

</announcements>
 
G

Guest

I have a code below i'm trying to test
It had a DataSetDatasource but i thinks its deprecated if yes what can i use
in this scenario below?
I used XmlDatasource but its saying it can't find the property url in the
xml which is there

Any ideas?
** XML datasource file below

<asp:XmlDataSource ID="DataSetDataSource1" Runat="server"
DataFile="~/data/Announcements.xml"/>

<asp:DataList ID="DataList1" Runat="server"
DataSourceID="DataSetDataSource1">

<ItemTemplate>

<table id="Table1" cellspacing="1" cellpadding="1" width="100%" border="0">

<tr>

<td valign="top" style="width: 80%">

<asp:HyperLink ID="TitleLabel" Runat="server" NavigateUrl='<%#
DataBinder.Eval(Container.DataItem, "url") %>'

Text='<%# DataBinder.Eval(Container.DataItem, "Title") %>'
Font-Names="verdana"

Font-Bold="True" Font-Size="8pt" ForeColor="#003399" />

<br />

by

<asp:Label ID="OwnerLabel" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Owner") %>'

ForeColor="#003399" />

</td>

<td style="text-align: right" align="right" valign="top">

<asp:Label ID="DateLabel" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Date") %>'

Font-Names="verdana" Font-Bold="True" Font-Size="8pt" ForeColor="#003399" />

</td>

</tr>

<tr>

<td colspan="2">

<asp:Label ID="DescriptionLabel" Runat="server" Text='<%#
DataBinder.Eval(Container.DataItem, "Description") %>' />

</td>

</tr>

</table>

</ItemTemplate>

</asp:DataList>

----------------------------------------------

<?xml version="1.0" encoding="utf-8" ?>

<announcements>

<announcement>

<id>1</id>

<title>New Intranet Portal Launched!</title>

<date>6/1/2003</date>

<owner>Star Developer</owner>

<description>Our new Company Intranet Portal has launched! Be sure to check
out the ultra cool personalization abilities.</description>

<url>~/sales.aspx</url>

</announcement>

<announcement>

<id>2</id>

<title>Top Customers Identified</title>

<date>6/1/2003</date>

<owner>Sales Manager</owner>

<description>We have identified our top customers based on orders placed.
Check out the Sales tab for more details.</description>

<url>~/default.aspx</url>

</announcement>

<announcement>

<id>3</id>

<title>Pay Day</title>

<date>5/15/2003</date>

<owner>President</owner>

<description>We have decided to double eveyone's paycheck this month.
Enjoy!</description>

<url>~/default.aspx</url>

</announcement>

</announcements>

This should work

<asp:XmlDataSource ID="DataSetDataSource1" Runat="server"
DataFile="~/data/Announcements.xml" XPath="announcements/
announcement" />

<asp:DataList ID="DataList1" runat="server"
DataSourceID="DataSetDataSource1">
<ItemTemplate>
<table id="Table1" cellspacing="1" cellpadding="1"
width="100%" border="0">
<tr>
<td valign="top" style="width: 80%">
<asp:HyperLink ID="TitleLabel"
runat="server" NavigateUrl='<%# XPath("url") %>' Text='<%#
XPath("title") %>' Font-Names="verdana"
Font-Bold="True" Font-Size="8pt"
ForeColor="#003399" />
<br />
by
<asp:Label ID="OwnerLabel"
runat="server" Text='<%# XPath("owner") %>' ForeColor="#003399" />
</td>
<td style="text-align: right"
align="right" valign="top">
<asp:Label ID="DateLabel"
runat="server" Text='<%# XPath("date") %>' Font-Names="verdana" Font-
Bold="True" Font-Size="8pt" ForeColor="#003399" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="DescriptionLabel"
runat="server" Text='<%# XPath("description") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
 
R

rote

Thanks alot
Anon User said:
This should work

<asp:XmlDataSource ID="DataSetDataSource1" Runat="server"
DataFile="~/data/Announcements.xml" XPath="announcements/
announcement" />

<asp:DataList ID="DataList1" runat="server"
DataSourceID="DataSetDataSource1">
<ItemTemplate>
<table id="Table1" cellspacing="1" cellpadding="1"
width="100%" border="0">
<tr>
<td valign="top" style="width: 80%">
<asp:HyperLink ID="TitleLabel"
runat="server" NavigateUrl='<%# XPath("url") %>' Text='<%#
XPath("title") %>' Font-Names="verdana"
Font-Bold="True" Font-Size="8pt"
ForeColor="#003399" />
<br />
by
<asp:Label ID="OwnerLabel"
runat="server" Text='<%# XPath("owner") %>' ForeColor="#003399" />
</td>
<td style="text-align: right"
align="right" valign="top">
<asp:Label ID="DateLabel"
runat="server" Text='<%# XPath("date") %>' Font-Names="verdana" Font-
Bold="True" Font-Size="8pt" ForeColor="#003399" />
</td>
</tr>
<tr>
<td colspan="2">
<asp:Label ID="DescriptionLabel"
runat="server" Text='<%# XPath("description") %>' />
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,065
Latest member
OrderGreenAcreCBD

Latest Threads

Top