Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Bjarne Fyrstenborg 1283 posts 4016 karma points MVP 8x c-trib
    Jul 14, 2012 @ 21:14
    Bjarne Fyrstenborg
    0

    List members related to node (an event)

    Hi..

    I'm trying to list events in a gridview and expand each gridview row to see which members who is related to these events/nodes.

    protected void FindTheGridAndBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType != DataControlRowType.DataRow) return;
                GridView nestedGridView = (GridView)e.Row.FindControl("GridViewNested");
    
                DataTable table = new DataTable();
    
                DataColumn myDataColumn = new DataColumn();
                myDataColumn.AllowDBNull = false;
                myDataColumn.AutoIncrement = true;
                myDataColumn.AutoIncrementSeed = 1;
                myDataColumn.AutoIncrementStep = 1;
                myDataColumn.ColumnName = "nested_auto_ID";
                myDataColumn.DataType = System.Type.GetType("System.Int32");
                myDataColumn.Unique = true;
                table.Columns.Add(myDataColumn);
    
                myDataColumn = new DataColumn();
                myDataColumn.ColumnName = "member_id";
                myDataColumn.DataType = System.Type.GetType("System.String");
                table.Columns.Add(myDataColumn);
    
                myDataColumn = new DataColumn();
                myDataColumn.ColumnName = "member_name";
                myDataColumn.DataType = System.Type.GetType("System.String");
                table.Columns.Add(myDataColumn);
    
                DataRow dataRow;
    
                Node specificNode = new Node(1248);
                Nodes events = specificNode.Children;
    
                RelationType member2doc = RelationType.GetByAlias("coming");
    
                foreach (Node year in events)
                {
                    foreach (Node month in year.Children)
                    {
                        foreach (Node eventNode in month.Children)
                        {
                            if (eventNode.NodeTypeAlias == "Event")
                            {
    
                                Relation[] relations = Relation.GetRelations(eventNode.Id, member2doc);
                                Member member;
    
    
                                foreach (Relation relation in relations)
                                {
                                    member = new Member(relation.Child.Id);
    
                                    dataRow = table.NewRow();
                                    dataRow["member_id"] = member.Id;
                                    dataRow["member_name"] = member.Text;
                                    table.Rows.Add(dataRow);
    
                                }
    
                            }
                        }
                    }
                }
    
                nestedGridView.DataSource = table;
                nestedGridView.DataBind();
            }

    But I think it's listing members related to each event/node .. so the same person is added multiple times..
    How can I list each member only once for each event?

    I think I'm using the same datatable values for each master-gridview row, so I get the same values in the nested gridview.

    The Content structure looks like this:

    /Bjarne

  • Bjarne Fyrstenborg 1283 posts 4016 karma points MVP 8x c-trib
    Jul 16, 2012 @ 19:59
    Bjarne Fyrstenborg
    0

    An example of the functionality I want is here: http://dotnetspeaks.com/LiveDemos/ASP.NET/GridView/NestedGridViewPaging.aspx

    with events in the master gridview and the related members to each event in the nested gridview.

    /Bjarne

  • Bjarne Fyrstenborg 1283 posts 4016 karma points MVP 8x c-trib
    Jul 18, 2012 @ 17:20
    Bjarne Fyrstenborg
    0

    How can I create a row foreach member in the relations and not foreach relation?

Please Sign in or register to post replies

Write your reply to:

Draft