I have a very simple RadListView populated from a DataSet:
Data:
ListView:
I thought I was being very cunning in my grouping efforts. The two method calls above are:
But when I run the page, I get this output:
What I should be getting is this?:
When I step through in debug I see the correct strings being returned but for the 5 rows in the DataSet, there are 10 calls to each method! It seems the second pass wipes the values from the first - but then, if that is the case, how did the Heading Twos get returned? I'm confused :)
Very strange. It works really well for the level 2 headings but not at all from the level one. Can anyone help?
Many thanks in advance,
Richard
Data:
| HeadingOne HeadingTwo DataValue |
| First Second Data Value |
| First Second Data Value |
| First Third Data Value |
| First Third Data Value |
| First Third Data Value |
ListView:
| <telerik:RadListView |
| ID="MyListView" |
| runat="server" |
| OnNeedDataSource="MyListView_OnNeedDataSource"> |
| <ItemTemplate> |
| <%# InsertHeadingOne() %> |
| <%# InsertHeadingTwo() %> |
| <p><%# Eval("DataValue") %></p> |
| </ItemTemplate> |
| </telerik:RadListView> |
I thought I was being very cunning in my grouping efforts. The two method calls above are:
| string lastHeadingOne = string.Empty; |
| string lastHeadingTwo = string.Empty; |
| protected string InsertHeadingOne() |
| { |
| string currentHeadingOne = Eval("HeadingOne").ToString(); |
| if (currentHeadingOne.Length == 0) |
| { |
| currentHeadingOne = string.Empty; |
| } |
| if (this.lastHeadingOne != currentHeadingOne) |
| { |
| this.lastHeadingOne = currentHeadingOne; |
| return string.Format("<h1>{0}</h1>", currentHeadingOne); |
| } |
| else |
| { |
| return string.Empty; |
| } |
| } |
| protected string InsertHeadingTwo() |
| { |
| string currentHeadingTwo = Eval("HeadingTwo").ToString(); |
| if (currentHeadingTwo.Length == 0) |
| { |
| currentHeadingTwo = string.Empty; |
| } |
| if (this.lastHeadingTwo != currentHeadingTwo) |
| { |
| this.lastHeadingTwo = currentHeadingTwo; |
| return string.Format("<h2>{0}</h2>", currentHeadingTwo); |
| } |
| else |
| { |
| return string.Empty; |
| } |
| } |
But when I run the page, I get this output:
| Second |
| Data Value |
| Data Value |
| Third |
| Data Value |
| Data Value |
| Data Value |
What I should be getting is this?:
| First |
| Second |
| Data Value |
| Data Value |
| Third |
| Data Value |
| Data Value |
| Data Value |
When I step through in debug I see the correct strings being returned but for the 5 rows in the DataSet, there are 10 calls to each method! It seems the second pass wipes the values from the first - but then, if that is the case, how did the Heading Twos get returned? I'm confused :)
Very strange. It works really well for the level 2 headings but not at all from the level one. Can anyone help?
Many thanks in advance,
Richard