Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
3550
Display list of lists
posted

I need to display list of lists in a hierarchical way.

This code shows it flat.

How to do?

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApplication25
{
    public partial class WebForm1 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<Item> ls = new List<Item>();
            Item it = new Item();
            it.x = 1;
            it.y = 2;
            ls.Add(it);
            Item it1 = new Item();
            it1.x = 4;
            it1.y = 5;
            ls.Add(it1);

            Item it2 = new Item();
            it2.x = 9;
            it2.y = 10;
            List<Item> ls1 = new List<Item>();
            ls1.Add(it2);

            Item it3 = new Item();
            it3.x = 13;
            it3.y = 14;
            List<Item> ls2 = new List<Item>();
            ls2.Add(it3);

            List<List<Item>> lsLs = new List<List<Item>>();
            lsLs.Add(ls);
            lsLs.Add(ls1);
            lsLs.Add(ls2);
         


            WebHierarchicalDataGrid1.DataSource = lsLs;
            WebHierarchicalDataGrid1.DataBind();
         
        }
    }
    public class Item
    {
        public int x { get; set; }
        public int y { get; set; }
    }
}