Connecting Tech Pros Worldwide Forums | Help | Site Map

LINQ to xml with grouping

Rick
Guest
 
Posts: n/a
#1: Aug 14 '08
VS 2008 Pro.

I'm writing an html report using LINQ to XML by accesing a datatable that I
filled with data.

the output is currently like this:

<html>
....
<table>
....
<tbody>
<%= From o In dt _
Select <tr>
<td><%= o.Field(Of
String)("Description") %></td>
<td><%= o.Field(Of
Int32)("Itemnum") %></td>
<td><%= o.Field(Of
String)("Name") %></td>
<td style="text-align:
right;"><%= o.Field(Of Int32)("OrderCount").ToString("N0") %></td>
<td style="text-align:
right;"><%= o.Field(Of Int64)("PacketTotal").ToString("N0") %></td>
<td style="text-align:
right;"><%= o.Field(Of Decimal)("TotalSold").ToString("N2") %></td>
</tr%>
</tbody>
</table>
</html>

I want to insert a new row <tr><td>... each time the field "Description"
changes and subtotal the "OrderCount", "Packettotal" and "TotalSold" fields.

I can't seem to find anything on Google, but it's probably just because I
don't know the proper question.

Can someone offer a sample or point me to some instructions?

Thanks,

Rick


Martin Honnen
Guest
 
Posts: n/a
#2: Aug 14 '08

re: LINQ to xml with grouping


Rick wrote:
Quote:
I want to insert a new row <tr><td>... each time the field "Description"
changes and subtotal the "OrderCount", "Packettotal" and "TotalSold"
fields.
>
I can't seem to find anything on Google, but it's probably just because
I don't know the proper question.
The VB.NET LINQ grouping construct is documented online here:
http://msdn.microsoft.com/en-us/library/bb531412.aspx


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Martin Honnen
Guest
 
Posts: n/a
#3: Aug 15 '08

re: LINQ to xml with grouping


Rick wrote:
Quote:
Your output is not valid html.
>
the general structure should be
<table>
<thead>...</thead>
<tbody><tr><td>...</td></tr><tr>...</tr><tr>...</tr></tbody>
</table>
>
All of the <trtags are located inside one <tbody>.
Sorry, that is not true, HTML tables allow several tbody elements, see
http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1, it says
<!ELEMENT TABLE - -
(CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
so you can have several tbody elements.




--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Rick
Guest
 
Posts: n/a
#4: Aug 15 '08

re: LINQ to xml with grouping


Thanks for pointing that out about multiple <tbodytags inside a table. I
don't do many html reports, but on occasion they are quick and convenient as
a reporting tool, especially now with LINQ.

Rick

"Martin Honnen" <mahotrash@yahoo.dewrote in message
news:%239722cs$IHA.4684@TK2MSFTNGP06.phx.gbl...
Quote:
Rick wrote:
>
Quote:
>Your output is not valid html.
>>
>the general structure should be
><table>
> <thead>...</thead>
> <tbody><tr><td>...</td></tr><tr>...</tr><tr>...</tr></tbody>
></table>
>>
>All of the <trtags are located inside one <tbody>.
>
Sorry, that is not true, HTML tables allow several tbody elements, see
http://www.w3.org/TR/html4/struct/tables.html#h-11.2.1, it says
<!ELEMENT TABLE - -
(CAPTION?, (COL*|COLGROUP*), THEAD?, TFOOT?, TBODY+)>
so you can have several tbody elements.
>
>
>
>
--
>
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Closed Thread


Similar .NET Framework bytes