Testrss. aspx:
<% @
Page
Language = "C #"
Autoeventwireup = "true"
Contenttype = "text/XML"
Codebehind = "testrss. aspx. cs"
Inherits = "namespace1.testrss"
%>
<Asp: Repeater
Id = "repeater1"
Runat = "server">
<Headertemplate>
<RSS
Version = "2.0">
<Channel>
<Title> ASP. NET news! </Title>
<Link> http://www.ASPNETNews.com/Headlines/ </link>
<Description>
This is the syndication feed for aspnetnews.com.
</Description>
</Headertemplate>
<Itemtemplate>
<Item>
<Title> <% # formatforxml (databinder. eval (container. dataitem,
"Title") %> </title>
<Description>
<% # Formatforxml (databinder. eval (container. dataitem,
"Description") %>
</Description>
<Link>
Http://www.ASPNETNews.com/Story.aspx? Id = <% #
Databinder. eval (container. dataitem, "ArticleID") %>
</Link>
<Author> <% # formatforxml (databinder. eval (container. dataitem,
"Author") %> </author>
<Pubdate>
<% #
String. Format ("{0: R }",
Databinder. eval (container. dataitem,
"Datepublished") %>
</Pubdate>
</Item>
</Itemtemplate>
<Footertemplate>
</Channel>
</RSS>
</Footertemplate>
</ASP: repeater>
Testrss3.aspx. Designer. CS:
Namespace namespace1 {
///
<Summary>
/// Testrss class.
///
</Summary>
///
<Remarks>
/// Auto-generated class.
///
</Remarks>
Public
Partial
Class
Testrss {
///
<Summary>
/// Repeater1 control.
///
</Summary>
///
<Remarks>
/// Auto-generated field.
/// To modify move field declaration from designer file to code-behind file.
///
</Remarks>
Protected
Global: system. Web. UI. webcontrols. Repeater repeater1;
}
}
Testrss. aspx. CS:
Using system;
Using system. Data;
Using system. configuration;
Using system. collections;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Namespace namespace1
{
Public
Partial
Class
Testrss: system. Web. UI. Page
{
Protected
Void page_load (Object sender, eventargs E)
{
Repeater1.datasource = getdataset ();
Repeater1.databind ();
}
Private
Dataset getdataset ()
{
Dataset1 dataset1 = new
Dataset1 ();
Datarow ROW = dataset1.tables [0]. newrow ();
Row ["title"] = "title1 ";
Row ["author"] = "author1 ";
Row ["Description"] = "description1 ";
Row ["datepublished"] = datetime. now;
Dataset1.tables [0]. Rows. Add (ROW );
Row = dataset1.tables [0]. newrow ();
Row ["title"] = "title2 ";
Row ["author"] = "author2 ";
Row ["Description"] = "description2 ";
Row ["datepublished"] = datetime. now;
Dataset1.tables [0]. Rows. Add (ROW );
Return dataset1;
}
Protected
String formatforxml (Object input)
{
String data = input. tostring (); // cast the input to a string
// Replace those characters disallowed in XML documents
Data = data. Replace ("&", "& amp ;");
Data = data. Replace ("\" "," & quot ;");
Data = data. Replace ("'", "& apos ;");
Data = data. Replace ("<", "& lt ;");
Data = data. Replace (">", "& gt ;");
Return data;
}
}
}