Database Records display like list<li>

Hello Experts

I am trying to create a Latest News section on homepage. Refer attachment for screenshot.

the latest news details are coded like this

<ul>
       <li>ajax</li>
       <li>browser</li>
       <li>cms</li>
       <li>css-html</li>
       <li>design</li>
      <li class="last">wordpress</li>
</ul>

now i cant understand how can i get it populated with database records. i know how to get the record set from the database but i am unable to get the User interface exactly like the screenshot.

I dont mind if i have to use datagrid, gridview, tables or anything but i need get the same look.

how can i achieve the desired result. Appreciate you help
LatestNews.jpg
LVL 9
AsishRajAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

guru_samiCommented:
You use a ListView Control  with DataPage or DataList Control
ListView sample:http://www.builderau.com.au/program/asp/soa/Display-data-with-NET-s-ListView-control/0,339028371,339287696,00.htm
0
ddayx10Commented:
Sometimes if I have an html layout that is working for me and I want to model it from a datasource such as SQL I will emit exactly the HTML I want from the code behind like this:

See EX:

Of course you'd have to add attributes like "class" and more elements like youre paging and title, but if you already have that working in HTML it's pretty cool to re-create it from code behind using data from SQL.
***ASPX***
    <div id="parentDiv" runat="server"></div>

****ASPX.CS****
    protected void Page_Load(object sender, EventArgs e)
    {
        SqlConnection conn = new SqlConnection(string.Format(@"Data Source=.\SQLEXPRESS;Integrated Security=True"));
        SqlCommand cmd = new SqlCommand("SELECT fName FROM DevTable",conn);

        HtmlGenericControl ul = new HtmlGenericControl("ul");

        conn.Open();
        SqlDataReader dr = cmd.ExecuteReader();

        while(dr.Read())
        {
            HtmlGenericControl li = new HtmlGenericControl("li");
            li.InnerHtml = dr["fName"].ToString();
            ul.Controls.Add(li);
        }
        
        dr.Close();
        conn.Close();

        parentDiv.Controls.Add(ul);
    }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AsishRajAuthor Commented:
thanks experts,

let me evaluate both the options and i will get back with the results.


0
Saqib KhanSenior DeveloperCommented:
you can also simply create a Literal Control and keep appending text to it and then assign its text value to Page's Div.

However I loved ddayx10's Solution. Neat & Clean.
0
AsishRajAuthor Commented:
Both the method works as i requested.

Thanks a lot for your help.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.