ColumnName | DataType |
ID | int |
Title | varchar(50) |
Description | varchar(50) |
Url | Varchar(50) |
ID | Title | Description | Url |
1 | Test | testing | http://aspdotnet-suresh.com |
2 | aspdotnet | aspdotnet-suresh | http://aspdotnet-suresh.com |
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@ OutputCache Duration="120" VaryByParam="*" %>
Step4: In code behind
using System; using System.Data; using System.Data.SqlClient; using System.Text; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml; public partial class GridviewEditUpdate : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { string connectionString = "Data Source=MYCBJ017550027;Initial Catalog=MySamplesDB;Integrated Security=True"; DataTable dt = new DataTable(); SqlConnection conn = new SqlConnection(connectionString); using (conn) { SqlDataAdapter ad = new SqlDataAdapter("SELECT * from tblRSS", conn); ad.Fill(dt); } Response.Clear(); Response.ContentType = "text/xml"; XmlTextWriter TextWriter = new XmlTextWriter(Response.OutputStream, Encoding.UTF8); TextWriter.WriteStartDocument(); //Below tags are mandatory rss TextWriter.WriteStartElement("rss"); TextWriter.WriteAttributeString("version", "2.0"); // Channel tag will contain RSS feed details TextWriter.WriteStartElement("channel"); TextWriter.WriteElementString("title", "C#.NET,ASP.NET Samples and Tutorials"); TextWriter.WriteElementString("link", "http://aspdotnet-suresh.blogspot.com"); TextWriter.WriteElementString("description", "Free ASP.NET articles,C#.NET,ASP.NET tutorials and Examples,Ajax,SQL Server,Javascript,XML,GridView Articles and code examples -- by Suresh Dasari"); TextWriter.WriteElementString("copyright", "Copyright 2009 - 2010 aspdontnet-suresh.blogspot.com. All rights reserved."); foreach (DataRow oFeedItem in dt.Rows) { TextWriter.WriteStartElement("item"); TextWriter.WriteElementString("title", oFeedItem["Title"].ToString()); TextWriter.WriteElementString("description", oFeedItem["Description"].ToString()); TextWriter.WriteElementString("link", oFeedItem["URL"].ToString()); TextWriter.WriteEndElement(); } TextWriter.WriteEndElement(); TextWriter.WriteEndElement(); TextWriter.WriteEndDocument(); TextWriter.Flush(); TextWriter.Close(); Response.End(); } } |
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
Subscribe by RSS
Subscribe by Email
|
|||
|
|

Subscribe by RSS
Subscribe by Email
15 comments :
small error in your code
1) //Below tags are mandatory rss tagTextWriter.WriteStartElement("rss"); should be two lines
//Below tags are mandatory rss tag
TextWriter.WriteStartElement("rss");
2)this gave an error so I deleted it
using System.Linq;
Otherwise it works great! :)
Thanks Dwayne thanks for rectify my mistake i modified the code now it's working fine
hey hi,
i create an application by following above procedure & steps but on front page i.e. on aspx page which control we should use to display rss feeds? plz tell me it's important for me.
@chinuexpert,
No need of any control just create the page based on above process and run it output will display.
grt work
nice post
awsome you are
Tell me something about Sharepoint also..
i got a result in xml format
thanx a lot sir
This feed contains errors. Internet Explorer will try updating this feed again later.iam getting this as result.Ihave 12 rows of data but display onli one row .
my result in xml format. how can i get rss feeds
in chrome....the result is xml format.how to get actual rss feeds
grt post
thanks
Hi, I want to create a RSS feed for a asp.net web page by using jquery.How should I do? please help me..