ASP.NET Datagrid from RSS Feed

liunx

Guest
I'm trying to pull XML data through an RSS Feed at: <!-- m --><a class="postlink" href="http://www.missingkids.com/missingkids/servlet/XmlServlet?act=rss&LanguageCountry=en_US&orgPrefix=NCMC&state=KS">http://www.missingkids.com/missingkids/ ... C&state=KS</a><!-- m -->
...into an ASP.NET Datagrid. Here's what I have so far on the ASP.NET page:

<%@ Page Language="VB" Debug="true" EnableSessionState="false" %>
<%@ import Namespace="System.Data" %>
<script runat="server">
'Pulls Amber Alert data from Center for Missing & Exploited Children RSS Feed for Kansas
Sub Page_Load
If Not Page.IsPostBack then
Dim xmlAmber = New DataSet
xmlAmber.ReadXml("http://www.missingkids.com/missingkids/servlet/XmlServlet?act=rss&LanguageCountry=en_US&orgPrefix=NCMC&state=KS")
aspxAmber.DataSource = xmlAmber
aspxAmber.DataBind()
End If
End Sub

</script>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Douglas County, Kansas - Amber Alert Information</title>
<!--#include virtual="/newsite/topborder.ssi" -->
</head>
<body>
<!--#include virtual="/newsite/topborder2.ssi" -->
<form runat="server">
<table width="660" border="0">
<tbody>
<tr valign="top">
<td width="75%">
<h1>Amber Alert Information</h1>
</td>
<td align="right">
<img height="32" alt="Back to Previous Page" src=http://www.webdeveloper.com/forum/archive/index.php/"http://www.douglas-county.com/images/back-sm.gif" width="46" />
</td>
</tr>
<tr>
<td colspan="2">
<!--Amber Alert data display begins-->
<asp:DataGrid id="aspxAmber" runat="server" AutoGenerateColumns="False" BorderWidth="0px" CellSpacing="1" CellPadding="1" Width="100%">
<ItemStyle verticalalign="Top"></ItemStyle>
<HeaderStyle font-bold="True" forecolor="White" bordercolor="White" backcolor="#330066"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="title" HeaderText="Missing Clild">
<HeaderStyle width="30%"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="item.link" HeaderText="Details Link">
<HeaderStyle width="15%"></HeaderStyle>
</asp:BoundColumn>
<asp:BoundColumn DataField="item.description" HeaderText="Brief Description">
<HeaderStyle width="15%"></HeaderStyle>
</asp:BoundColumn>
</Columns>
</asp:DataGrid>
<!--Amber Alert data display ends-->
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>

But I keep getting this error message:

A field or property with the name 'title' was not found on the selected datasource.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: A field or property with the name 'title' was not found on the selected datasource.
Source Error:
Line 8: xmlAmber.ReadXml("http://www.missingkids.com/missingkids/servlet/XmlServlet?act=rss&LanguageCountry=en_US&orgPrefix=NCMC&state=KS")
Line 9: aspxAmber.DataSource = xmlAmber
Line 10: aspxAmber.DataBind()
Line 11: End If
Line 12: End Sub

I've also tried changing the "DataField="title"" to "DataField="item.title"" because there are several instances of "title" within the same XML doc, but I still get the same error message. What am I doing wrong with this? I hope that it's something simple.You may have the field name incorrect and there may be multiple tables. I'd suggest that you create a datagrid with autogeneratecolumns=true and databind it to xmlAmber.Tables(0) then xmlAmber.Tables(1), etc. This way you can better understand the structure of your dataset and work with that.
 
Back
Top