Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
I have been working on Rss Feed project for quite sometime now, i am trying to dynamically populate a repeater with corresponding description when a title is clicked. here is my code:

XML
        <asp:XmlDataSource ID="XmlDataSource1" runat="server"
                DataFile="http://www.channelstv.com/home/feed/"
                XPath="rss/channel/item[position()<6]">
            </asp:XmlDataSource>
                <br />
             <asp:Repeater ID="Repeater1" runat="server" DataSourceID="XmlDataSource1" >
            <ItemTemplate>

           <a href="Default.aspx?News=<%# XPath("title")%>"><%#XPath("title")%></a> <br />--%>

                 <%#DateTime.Parse(XPath("pubDate").ToString()).ToString("MMMM dd, yyyy")%>
                 <hr style="color:#0099ff;" /><br />
            </ItemTemplate>
        </asp:Repeater>

the above code will display 5 feed title and publish date, i want to be able to display corresponding description for each title on another page when any of the link is clicked. Please idea will be appreciated. Thanks in advance.
Posted
Comments
So, what is the issue?
Uwakpeter 10-Jan-14 12:49pm    
This my code will display five feed title as links, when a user clicks on any of the feed title, he or she will be redirected to Default.aspx, I want to be able to display the feed title that was clicked and corresponding feed description on Default.aspx. Thanks.
So, is it not reflecting the values in Default.aspx page for every link?
Uwakpeter 10-Jan-14 23:28pm    
Yes sir, I want to display description that comes with each title on Default.aspx
Check the HTML of the page and see what is the href value showing on each link.

The solution for this is already in your code.
Put a label somewhere on your Defailt.aspx page and get the title from the query string like this.

Request.QueryString("News")
 
Share this answer
 
Comments
Uwakpeter 10-Jan-14 14:37pm    
Yes I have been able to display the title and description Default.aspx using the querystring, but it is only the first title and corresponding description that always displayed, I want to be able to display such that the title and description will change on every link that is clicked. Thanks...
Quote:
yes it works but it is using plus sign, is there anyway i can encode with a minus sign or dash?
No, you can't do that directly.

But you can do like...
1. How does Stack Overflow generate its SEO-friendly URLs?[^]

OR


Just replace before encoding like...
JavaScript
<a href="Default.aspx?News=<%# HttpUtility.UrlEncode(XPath(" title=").ToString().Replace(" ", "_"))%>">

If you want to use Replace some characters again, then you can do like...
C#
HttpUtility.UrlEncode(XPath(" title=").ToString().Replace(" ", "_").Replace("CharacterToReplace", "NewCharacter").Replace("CharacterToReplace", "NewCharacter"))

Use as many times you want. :)
 
Share this answer
 
Comments
Uwakpeter 15-Jan-14 7:05am    
It works, Thanks so much, i really appreciate
Most Welcome buddy. Anytime. :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900