Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Nested lists in Asp.net page

Nested lists in Asp.net page

Scheduled Pinned Locked Moved ASP.NET
csharpasp-netwpfhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    G Ringbom
    wrote on last edited by
    #1

    I am getting crazy with this problem. I am working on a page that is to display the milestones in a project. Each milestone contains a number of document templates that are to be listed under their correct milestone. This would create something like nested lists and I have absolutely no idea of how to do them. Right now I can only list the milestones. I do this with a repeater. Now I need a way to get into each row of this repeater and show the templates there. I have read articles on the net about nesting repeaters but they dont apply to the way I have constructed my code. They rely completely on a dataset and that you add relations in this dataset. I have one arraylist with objects that describe the milestones. For each milestone I get another arraylist containing the templates for that specific milestone. Please if you have any idea of how to show all this data please tell me. I am not required to use a repeater so any other idea will be helpful aswell. Thanks

    M 1 Reply Last reply
    0
    • G G Ringbom

      I am getting crazy with this problem. I am working on a page that is to display the milestones in a project. Each milestone contains a number of document templates that are to be listed under their correct milestone. This would create something like nested lists and I have absolutely no idea of how to do them. Right now I can only list the milestones. I do this with a repeater. Now I need a way to get into each row of this repeater and show the templates there. I have read articles on the net about nesting repeaters but they dont apply to the way I have constructed my code. They rely completely on a dataset and that you add relations in this dataset. I have one arraylist with objects that describe the milestones. For each milestone I get another arraylist containing the templates for that specific milestone. Please if you have any idea of how to show all this data please tell me. I am not required to use a repeater so any other idea will be helpful aswell. Thanks

      M Offline
      M Offline
      Mike Ellison
      wrote on last edited by
      #2

      Hi there. You should be able to accomplish what you want by declaring within your main Repeater's ItemTemplate the nested control (probably another Repeater in your case). Then code an event handler for the main Repeater's ItemDataBound[^] event. Here's an example using an ArrayList for the main data source; each object in the main ArrayList has its own ArrayList of nested objects used for the nested data source.

      <%@ Page Language="C#" %>
      <script runat="server">

      void Page_Load(object o, EventArgs e)
      {
      if (!IsPostBack) BindMainData();
      }

      ArrayList GetMainDataSource()
      {
      // return an arraylist of objects to represent the main datasource
      ArrayList arr = new ArrayList();
      MainObject m;

      m = new MainObject("First Main Object");
      m.NestedObjects.Add(new NestedObject("main 1, first nested object") );
      m.NestedObjects.Add(new NestedObject("main 1, second nested object") );
      m.NestedObjects.Add(new NestedObject("main 1, third nested object") );
      arr.Add(m);
       
      m = new MainObject("Second Main Object");
      m.NestedObjects.Add(new NestedObject("main 2, first nested object") );
      m.NestedObjects.Add(new NestedObject("main 2, second nested object") );
      m.NestedObjects.Add(new NestedObject("main 2, third nested object") );
      arr.Add(m);
       
      m = new MainObject("Third Main Object");
      m.NestedObjects.Add(new NestedObject("main 3, first nested object") );
      m.NestedObjects.Add(new NestedObject("main 3, second nested object") );
      m.NestedObjects.Add(new NestedObject("main 3, third nested object") );
      arr.Add(m);
      
      return arr;
      

      }

      void BindMainData()
      {
      // bind the main datasource
      rptMain.DataSource = GetMainDataSource();
      rptMain.DataBind();
      }

      void rptMain_ItemDataBound(object o, RepeaterItemEventArgs e)
      {
      if (e.Item.ItemType == ListItemType.Item
      || e.Item.ItemType == ListItemType.AlternatingItem)
      {
      // if this is a normal item type, then locate the nested repeater
      Repeater rpt = e.Item.FindControl("rptNested") as Repeater;
      i

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups