locked
Is it possible to condense duplicate data rows in repeater RRS feed

  • Question

  • User821012182 posted

    Pretty sure I already know that answer but wanted to check the guru section first. Is it possible to display the non-duplicate data in a dataset within a repeater?  What I mean by that is this.  If I have a dataset like:

    The data returned will only have one attribute (column) that will have varying data.  

    0500-0000001079 | install new mxb402sc on manager computer | kim also wants to update java
    0500-0000001079 | install new mxb402sc on manager computer | also need to order a pc kit for her dell 2350d
    0500-0000001079 | install new mxb402sc on manager computer | ordered dell pc kit for kim
    0500-0000001079 | install new mxb402sc on manager computer | Audit Ticket: 0500-1079 Status, Close Date Time
    0500-0000001086 | No internet in G108 | home lost power and the internet has not come back
    0500-0000001086 | No internet in G108 | having the resident power the cycle in wall switch

    You can see that column 3 is always different.  Column 1 and 2 are values that repeat and would prefer to consolidate into one distinct "row" in the output with Column 3 data repeating down like so:

    0500-0000001079 install new mxb402sc on manager computer
    - kim also wants to update java
    - also need to order a pc kit for her dell 2350d
    - ordered dell pc kit for kima
    - Audit Ticket: 0500-1079 Status, Close Date Time
    0500-0000001086 No internet in G108
    - home lost power and the internet has not come back
    - having the resident power the cycle in wall switch

    Is this possible or would it be better to separate it out into two data sets and use a nested repeater? Trying to use as few calls to the data as possible.  Thanks in advance.  

    FYI using VB so any examples please use VB.  

    Wednesday, April 22, 2015 7:40 PM

All replies

  • User-1516073966 posted

    Hi,

    Can you try the following:

    <div>
                <asp:Repeater ID="pList" runat="server">
                    <ItemTemplate>
                        <div style="border: solid thin red;">
                            <asp:Label ID="lblName" runat="server" Text='<%# Eval("ProductID") %>'></asp:Label>
                            &nbsp; &nbsp;                        
                            <asp:Label ID="Label2" runat="server" Text='<%# Eval("Name") %>'></asp:Label>
                            <ul>
                                <asp:Repeater ID="lstComments" runat="server" DataSource='<%# Eval("Comments") %>'>
                                    <ItemTemplate>
                                        <li><%# Eval("CommentList") %>'></li>
                                    </ItemTemplate>
                                </asp:Repeater>
                            </ul>
                        </div>
                    </ItemTemplate>
                </asp:Repeater>
    </div>

    DataTable table = new DataTable();
                table.Columns.Add("ID");
                table.Columns.Add("ProductName");
                table.Columns.Add("Comments");
    
                table.Rows.Add("0500-0000001079", "install new mxb402sc on manager computer", "kim also wants to update java");
                table.Rows.Add("0500-0000001079", "install new mxb402sc on manager computer", "also need to order a pc kit for her dell 2350d");
                table.Rows.Add("0500-0000001079", "install new mxb402sc on manager computer", "ordered dell pc kit for kim");
                table.Rows.Add("0500-0000001079", "install new mxb402sc on manager computer", "Audit Ticket: 0500-1079 Status, Close Date Time");
    
                table.Rows.Add("0500-0000001086", "No internet in G108", "having the resident power the cycle in wall switch");
                table.Rows.Add("0500-0000001086", "No internet in G108", "home lost power and the internet has not come back ");
    
                var result = (from p in table.AsEnumerable()
                              group p by p.Field<string>("ID") into PID
                              select new
                              {
                                  ProductID = PID.Key,
                                  Name = table.AsEnumerable().First(dr => dr.Field<string>("ID") == PID.Key).Field<string>("ProductName"),
                                  Comments = (from p1 in table.AsEnumerable()
                                              where p1.Field<string>("ID").Equals(PID.Key)
                                              select new { CommentList = p1.Field<string>("Comments") }
                                                )
                              });
                pList.DataSource = result;
                pList.DataBind();

    Thursday, April 23, 2015 6:27 AM
  • User-330204900 posted

    Is this a Dynamic Data Project?

    Thursday, April 23, 2015 6:45 AM
  • User821012182 posted

    Yes. The information will be derived from a SQL query.  What I am doing is returning Tickets and their associated history from an archaic ticketing system to make it searchable.  I have 6 attributes of Ticket and 1 (notes) of history.   I know I could isolate the ticket id from a query and then query the history table and nest that inside the ticket repeater.  What I was hoping to do is isolate the query to one query that include the ticket information and the history information.  The Ticket information would duplicate for every history record like I show in my earlier post.  

    If that is possible that would be wonderful and save traffic and bandwidth.  The software has an API but it is a massive resource hog so searches take an exponential amount of time.  ODBC connections are all but instantaneous so I am am trying to scrape the rust off my .Net skills. 

    Thursday, April 23, 2015 11:39 AM