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 + "<br /> <br />" + Convert.ToString(dr[j]) + "</font></b>"; 
            }

        }

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

Thanks :)

Recommended Answers

All 2 Replies

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

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 :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.