Is it possible to do custom grouping in the ASP.NET ListView control?

前端 未结 3 952
无人共我
无人共我 2021-01-18 06:27

You can only define a GroupItemCount in the ListView, but what if you want to do grouping based on a property of the items in the data source? Sort of an ad-hoc group by. Th

3条回答
  •  情深已故
    2021-01-18 06:58

    When I had to add basic group headings in a repeater I did so with a Literal control in the ItemTemplate:

    
    

    The 'GetGroupHeading' method in the code kept track of the previous group heading and sent back '

    Group Name

    ', or an empty string if we were on the same group as the previous item. As I said though, I did this on a Repeater, so not sure if it will cover what you need for a ListView.

提交回复
热议问题