473,383 Members | 1,859 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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

Aug 14 '08 #1
3 1505
Rick wrote:
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/
Aug 14 '08 #2
Rick wrote:
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/
Aug 15 '08 #3
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" <ma*******@yahoo.dewrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
Rick wrote:
>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/
Aug 15 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: ahaque38 | last post by:
Hello. Using A2K SP3, I am having the following problem with a report using "Sorting and Grouping". I have recently added a grouping in the reports for "Category2<>'CONTRACTS'". I have...
1
by: Bob Johnson | last post by:
Just wondering if LINQ might be useful and appropriate in the following scenario: I'm writing a Windows Forms app that enables the user to search for a "client account". The client account is...
3
by: Dean Slindee | last post by:
I'm confused. After all these years of promoting 3-tier architecture, isn't LINQ moving us back to a 2-tier architecture (no stored procedures?). Are there scenarios where LINQ would be a better...
1
by: webby98 | last post by:
I have an issues using LINQ and nested gridview. Let me explain, Gridview A are the for grouping. And Gridview B are place in between Gridview A to display list data relate to Gridview A...
9
by: =?Utf-8?B?cmF1bGF2aQ==?= | last post by:
Hi all: after reading different places/sites about linq... I ran into these questions: 1. What framework do we need to run linq ? (does it depend on what version of visual studio we have?) how...
5
by: Seb | last post by:
I want to count activity in a given month. I'm trying to do so with the linq code below however it reports: Error 1 'a' is inaccessible due to its protection level var ActivityByMonths = from a...
0
by: =?Utf-8?B?SHlwZXJjb2Rlcg==?= | last post by:
I'm encountering some strange behavior after deploying a ASP.net 3.5 website to production, i'm unable to reproduce these in my dev environment. This error seems to occur very randomly but it's...
1
by: DaveD | last post by:
Let's say I have a collection ("items") of objects that each have a "string Name" property. I understand I can create a loop like this: foreach (string name in names) { var item = (from x in...
3
by: =?Utf-8?B?UGF1bCBQcmV3ZXR0?= | last post by:
I'm attempting to use LINQ to insert a record into a child table and I'm receiving a "Specified cast is not valid" error that has something to do w/ the keys involved. The stack trace is: ...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.