473,471 Members | 4,625 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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 13150
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: | last post by:
Hello All, I am having a lot of difficulty trying to bind a templated column, that is programmatically created for a datagrid, to a datasource column. I have a datasource containing 2 columns,...
2
by: Robert Smith jr. | last post by:
Hello, Please pardon my newbie question ... I am building an ASP.NET page that displays a recordset with a Delete statement enabled (this all works fine). I want to Insert the current row...
1
by: Rob | last post by:
This may be a really dumb question but is there any way to manually read the data in a datasource???? Is binding a datasource to a control the only way to see and manipulate the actual data?? ...
0
by: yossimotro | last post by:
Hi, I'm using a gridview in my project and its footer to add new records. The gridview is connected to an AccessDataSource which contains select, insert and delete commands. The problem...
3
by: Jeff | last post by:
Hey asp.net 2.0 In the source I posted below, there is a GridView (look at the bottom of the script): <asp:GridView ID="gvwOnline" runat="server"> </asp:GridView> I'm trying to assign a...
3
by: Pika | last post by:
I have a gridview with some data and I need to access to this data through javascript. Can someone help me.
4
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
3
by: eselk2003 | last post by:
I'm just starting out with VWD 2008, and new to ASP .NET. I have a master page which displays one record for an Access database based on an ID number in the query string. Then I have a content...
1
by: sadaiyan | last post by:
Hello peoples, I have working in asp.net project , i am showing details in gridview and also showing gridview button control in the templatefield now i want to delete the current row when i click on...
1
by: miladhatam | last post by:
hi how can i show every 10 records of my db in datalist in several page i want to get it the paging property i even wrote this code AccessDataSource1.SelectCommand = "SELECT * FROM table1 where...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.