954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Retrieving Data like Blog Posts?

Hello Friends! :)

I am working on my College Major Project.

My project contains a part, where the Admin will post News (using Editor like a Blog).

This News is then stored in Database.

Now I want to retrieve "top 2" news and post them on Home page.

I am retirieving data and displaying it all in a Label Control on Home page.

I want to provide the following Format to the News :

Title With Hyperlink

News News News....
....
...
..... News.


I am using the following Code to retrieve the data, but I am not able the get the above mentioned layout.

foreach (DataRow dr in DS.Tables[0].Rows)
        {
            
            for (int j = 0 ; j < 2 ; j++)
            {

                lblNews.Text = "<b> <font size=4>" + lblNews.Text + " " + Convert.ToString(dr[j]) + "</font></b>"; 
            }

        }


Is there any other way to access all the Retrieved data?

Thanks :)

dhavalcoholic
Newbie Poster
21 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

Hello There..try this..
this code is not so sofasticated but u will get help..

Label1.Text = "";
        string[] listofNews ={ "News", "News", "News", 
                               "News", "News", "News", 
                               "News", "News", "News",
                               "News","News","News" };
        Label1.Text = "<br/>";
        for (int i = 0; i < listofNews.Length; i++)
        {
            Label1.Text += "<b><a href='#'>&nbsp;&nbsp;" + listofNews[i].ToString() + "&nbsp;&nbsp;</a></b>";
            if (i == 2)
            {
                Label1.Text += "<br/>";
            }
            else if (i == 5)
            {
                Label1.Text += "<br/>";
            }
            else if (i == 8)
            {
                Label1.Text += "<br/>";
            }
            
        }


Try it out..by your own for inside loop okk

amitshrivas
Light Poster
31 posts since Sep 2009
Reputation Points: 10
Solved Threads: 3
 

I think I framed the question in wrong fashion.

I want to display content like it is done in Wordpress.

Eg: On Wordpress's Main Page, you see top few posts. And when you click on their Title, you go to another page where you can read the whole post.

This is what I am trying to do :)

dhavalcoholic
Newbie Poster
21 posts since Feb 2009
Reputation Points: 10
Solved Threads: 0
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: