PC Review


Reply
Thread Tools Rate Thread

Aggregates of datatables and 3 tier architecture

 
 
JimLad
Guest
Posts: n/a
 
      19th May 2010
Hi,

I have a listview on a page which binds to an objectdatasource which
returns a typed datatable as the select command. There are also
Update, Insert and Delete commands.
I need to display the sum of a couple of these columns and a max and
min of another column.
What is the best way of doing this?

I could:
- Hack around with the listview.
- Run Compute on the datatable.
- Run separate aggregating sproc on the source database.

The middle one seems to be best but I can't see how to get access to
the datatable without causing another call to the database
(essentially calling GetData twice on the tableadapter - once manually
and once thropugh the automated databind). The datatable is not
accessible from the listview or the objectdatasource as far as I can
tell (databind is handled automatically and I don't really want to do
it manually).

Thanks in advance for any help.

James




 
Reply With Quote
 
 
 
 
JimLad
Guest
Posts: n/a
 
      19th May 2010
On 19 May, 17:15, JimLad <jamesdbi...@yahoo.co.uk> wrote:
> Hi,
>
> I have a listview on a page which binds to an objectdatasource which
> returns a typed datatable as the select command. *There are also
> Update, Insert and Delete commands.
> I need to display the sum of a couple of these columns and a max and
> min of another column.
> What is the best way of doing this?
>
> I could:
> - Hack around with the listview.
> - Run Compute on the datatable.
> - Run separate aggregating sproc on the source database.
>
> The middle one seems to be best but I can't see how to get access to
> the datatable without causing another call to the database
> (essentially calling GetData twice on the tableadapter - once manually
> and once thropugh the automated databind). The datatable is not
> accessible from the listview or the objectdatasource as far as I can
> tell (databind is handled automatically and I don't really want to do
> it manually).
>
> Thanks in advance for any help.
>
> James


Why is it that you spent hours thinking about something and it becomes
clear the moment you put it on a newsgroup? Doh!
The key is the ObjectDataSource.Selected event. e.ReturnValue give you
your datatable or whatever else is the datasource.

Private Sub ObjectDataSource_Selected(ByVal sender As Object,
ByVal e As System.Web.UI.WebControls.ObjectDataSourceStatusEventArgs)
Handles ObjectDataSource.Selected
Dim dataTable As DataTable = CType(e.ReturnValue, DataTable)
TotalLabel.Text = dataTable.Compute("Sum(total)", "").ToString
Dim minEndDateObjectAs Object =
dataTable.Compute("Min(end_date)", "")
If MinEndDateTextBox.Text = "" AndAlso
IsDate(minEndDateObject) Then
MinEndDateTextBox.Text =
CDate(minEndDateObject).ToString("d")
End If
End Sub

James

 
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
3-Tier Architecture that uses com+ pbearne@gmail.com Microsoft ASP .NET 1 5th Jun 2007 09:46 AM
3 Tier architecture Dan, Vascas Microsoft Dot NET Framework Forms 2 31st Mar 2006 07:46 PM
N Tier Architecture ? Silent Ocean Microsoft ADO .NET 2 11th Aug 2005 03:48 PM
N Tier Architecture ? Silent Ocean Microsoft ASP .NET 2 11th Aug 2005 01:48 PM
Message board layered architecture 2-tier or 3-tier? Vin Microsoft Dot NET 0 22nd Jul 2004 07:46 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 02:55 AM.