How to create Ordered List in ASP.NET

For almost all HTML controls there are its corresponding ASP.NET controls. For HTML ‘Div’ there is its ASP.NET counterpart ‘Panel’, for HTML ‘Span’ there is ASP.NET ‘Label’.

Likewise for HTML ‘Ul’ (Unordered list) there is Bulleted List.

Both HTML Unordered list control and ASP.NET Bulleted list control have their own advantages and disadvantages, like – -> We can not bind any Data Source to HTML Unordered List, but when using ASP.NET Bulleted List we can do it. -> Adding any child controls to each list item (

  • ) is not possible in case of Bulleted List but is possible in case of HTML Unordered list.

    -> There is no counter part for HTML Ordered list in ASP.NET.

    However, there some questions in my mind – 1. Can we create Ordered List in ASP.NET?

    2. Can we use any child element like link () inside the list item?

    Lets come to the first question: Can we create Ordered list in ASP.NET ? Few days ago I was also asking this question to myself, then i thought of creating HTML Ordered list and add runat=”server” tag to make it available at server side. But unfortunately DataBinding is not supported in HTML Ordered list.

    To support DataBinding you can use a special ASP.NET control which will solve the both problems. The special control in Repeater control.

    Sample Code:

        
    1. List lstName = new List(); lstName.Add(new EmpName { Name = “Devi” }); lstName.Add(new EmpName { Name = “Prasad” }); lstName.Add(new EmpName { Name = “Das” }); rptEmpName.DataSource = lstName; rptEmpName.DataBind();
  • 150 150 Burnignorance | Where Minds Meet And Sparks Fly!