471,350 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

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

How to access the datasource of a GridView

Hi,

I am using a GridView and have it bound to a ObjectDataSource.
After the binding has been successfull, I need to access the original
datasource (which I guess is a DataSet) to display some reporting
information.

Anyone any idea how to do this?

I think I need to grab the DataSet returned from the DataObjectMethod,
loop round it and add up the columns I need for reporting. Crude I know,
but does anyone have a better suggestion for this?

Here is ane example of what I need to display:

//Original Databound GridView

Amount Type Source
10 V S
15 V K

//Then on a seperate GridView I want a little summary report:

Total Amount
25

I don't want to go back to the Database for this information as the
query to get this information (a lot more complex than the above
example) is very expensive.

Any help / alterantives on this would be appreciated.

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***
Feb 7 '06 #1
2 13067
Steven,

See inline:
I am using a GridView and have it bound to a ObjectDataSource.
After the binding has been successfull, I need to access the original
datasource (which I guess is a DataSet) to display some reporting
information.
Why would it be a dataset? ObjectDataSource instances are used to get
data from objects, not from data sets.
Anyone any idea how to do this?
You would need the data in data set format, not an object.
I think I need to grab the DataSet returned from the DataObjectMethod,
loop round it and add up the columns I need for reporting. Crude I know,
but does anyone have a better suggestion for this?

Here is ane example of what I need to display:

//Original Databound GridView

Amount Type Source
10 V S
15 V K

//Then on a seperate GridView I want a little summary report:

Total Amount
25

I don't want to go back to the Database for this information as the
query to get this information (a lot more complex than the above
example) is very expensive.
I would recommend a data set to populate this. This way, you can know
exactly what the structure of the data source is, and tally up whatever you
need to. Either that, or figure out what object you are connecting to the
grid through the object data source.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

Any help / alterantives on this would be appreciated.

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***

Feb 7 '06 #2
Steven,

Assuming that your ODS returns a DataTable:

protected void ObjectDataSourceMain_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
// bubble exceptions before we touch e.ReturnValue
if (e.Exception != null) throw e.Exception;

// get the DataTable from the ODS select mothod
DataTable dataTable = (DataTable)e.ReturnValue;

// ...
}

You can do the same thing with a DataSet. You need to wire up the Selected
event and make sure to check for exceptions within this code as I did in the
above example.

Hope this helps,

--

Andrew Robinson
http://blog.binaryocean.com

"Steven Blair" <st**********@btinternet.com> wrote in message
news:%2******************@TK2MSFTNGP11.phx.gbl...
Hi,

I am using a GridView and have it bound to a ObjectDataSource.
After the binding has been successfull, I need to access the original
datasource (which I guess is a DataSet) to display some reporting
information.

Anyone any idea how to do this?

I think I need to grab the DataSet returned from the DataObjectMethod,
loop round it and add up the columns I need for reporting. Crude I know,
but does anyone have a better suggestion for this?

Here is ane example of what I need to display:

//Original Databound GridView

Amount Type Source
10 V S
15 V K

//Then on a seperate GridView I want a little summary report:

Total Amount
25

I don't want to go back to the Database for this information as the
query to get this information (a lot more complex than the above
example) is very expensive.

Any help / alterantives on this would be appreciated.

Regards,

Steven

*** Sent via Developersdex http://www.developersdex.com ***

Feb 7 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Robert Smith jr. | last post: by
1 post views Thread by Rob | last post: by
reply views Thread by yossimotro | last post: by
3 posts views Thread by Jeff | last post: by
3 posts views Thread by eselk2003 | last post: by
1 post views Thread by miladhatam | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.