Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

grouping data in a listview/datagrid/dataview? (any of) 1

Status
Not open for further replies.

NoCoolHandle

Programmer
Apr 10, 2003
2,321
US
Hi.

In reporting services you can toss a query at a report that returns records that have duplicate column data in them.

For instance all the order items for all your orders.

You can then set a "grouping" based on the order id and remove the duplicate data (orderid) from each specific order.

Can this be duplicated / achieved using any of the built in data controls.

TIA

Rob
 
you could nest repeaters within each other and build out the html.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Jason, If I ever get a chance to meet you I owe you a good few beers. THanks for the thought.. I never thought about that.

Rob
 
I had no luck with the repeater. Ram used by IE got to 300meg before terminated the browser. Looked on line. Got confused..

So.. I did attacked ListView and the DataList and found a really and easy solution. No nesting.

Works with both sqldatasources and datasets

The trick was to intersept the appropriate objects OnItemDataBound event and then look to see if it was the same last time.

basic idea
Code:
--In VB--

Protected Sub LVItemDB(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs)
        If e.Item.ItemType = ListViewItemType.DataItem Then
            Dim strval As String = CType(e.Item.FindControl("TitleLabel"), Label).Text
            Dim title As String = ViewState("lvtitle")
            If title = strval Then
                CType(e.Item.FindControl("TitleLabel"), Label).Text = ""
            Else
                title = strval
                ViewState("lvtitle") = title
                CType(e.Item.FindControl("TitleLabel"), Label).Text = title
            End If
        End If
    End Sub


--Page--
<asp:ListView ID="ListView1" runat="server" DataSourceID="SqlDataSource1" [b]OnItemDataBound="LVItemDB"[/b] >
etc...
</asp:listView>

I will post the full source for both datasets on my home server. (they will work with the nortwind database)



Have Fun.

Rob

PS if you can post an easy example of nesting a repeater to a datatable could you post it or a link to the soultion here..(tia)
 
nested repeaters (or nested anything) works best with parent child objects, rather than flat tables. so if you have a a dataset with 2 tables, or a list of parents that contain children repeaters work well.

Jason Meckley
Programmer
Specialty Bakers, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top