[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

Re: Grouping Data with a Repeater Control

Jason

1/15/2003 7:15:00 AM

Eric,

Thankyou very much for your reply. Based on what you suggested I was
able to come up with the following solution. I hope this will be of some
use to other developers. :)

Okay in the page code I created the following variable outside of the
procedures:
Dim strCategory as String

I used this to track the last category displayed.

Then I set my ItemTemplate as follows:
<ItemTemplate>
<%# RetrieveCategory(Container.DataItem("Category")) %>
<tr>
<td><%# Container.DataItem("Field1") %></td>
<td><%# Container.DataItem("Field2") %></td>
</tr>
</ItemTemplate>

Then the RetrieveCategory Function:
Public Function RetrieveCategory(ByVal pstrCategory As _ String) As
String
If Not (strCategory = pstrCategory) Then
strCategory = pstrCategory
RetrieveCategory = "<tr><td colspan = 2>" & _
strCategory & _
"</td></tr>"
Else
RetrieveCategory = vbNullString
End If
End Function

I hope this is clear. One other consideration I should address is that I
used the function to output the table tags. If the category has changed
it puts the table row in, and if it hasen't it doesn't insert anything
thus keeping my table nice & neat. :)

Thanks for your help Eric. :)

*** Sent via Developersdex http://www.develop... ***
Don't just participate in USENET...get rewarded for it!