Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 14th, 2008, 01:45 PM
Rick
Guest
 
Posts: n/a
Default LINQ to xml with grouping

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

  #2  
Old August 14th, 2008, 02:35 PM
Martin Honnen
Guest
 
Posts: n/a
Default 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/
  #3  
Old August 15th, 2008, 12:15 PM
Martin Honnen
Guest
 
Posts: n/a
Default 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/
  #4  
Old August 15th, 2008, 12:35 PM
Rick
Guest
 
Posts: n/a
Default 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/
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles