473,591 Members | 2,923 Online
Bytes | Software Development & Data Engineering Community
+ 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 ObjectDataSourc e.
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 DataObjectMetho d,
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 13160
Steven,

See inline:
I am using a GridView and have it bound to a ObjectDataSourc e.
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? ObjectDataSourc e 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 DataObjectMetho d,
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.co m

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 ObjectDataSourc eMain_Selected( object sender,
ObjectDataSourc eStatusEventArg s 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.Re turnValue;

// ...
}

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**********@b tinternet.com> wrote in message
news:%2******** **********@TK2M SFTNGP11.phx.gb l...
Hi,

I am using a GridView and have it bound to a ObjectDataSourc e.
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 DataObjectMetho d,
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
2107
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, ID and VALUE. I would like to create a templated column in the datagrid that is bound to the VALUE column of the datasource.
2
6538
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 *that is going to be deleted* into another table, before the original data is deleted. I am trying to use the RowDeleting method to call an Update or Insert
1
999
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?? If I want to read a value from a database in code, is there any way to do with a datasource? Or is the old .net way with sql or ODBC objects the only way to read and manipulate data in code? Thanks in advance
0
946
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 occurs when the AccessDataSource is empty, the gridview won't show at all, not even the footer so I can't add new data. I know I can give up on the footer and just create somelike myself
3
4596
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 datasource to this GridView in runtime. But I cannot
3
2246
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
9776
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 sounds easy but the next requirement is that the GridView is editable. So I have included the SelectCommand and the UpdateCommand on the SqlDataSource to allow the GridView to be editable. I have now been able to get the GridView to display data...
3
1270
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 page that displays some other records which are also filtered by that ID. I'd like to do just one query in the master page, which returns all fields for that main record, then just use those fields in the details page instead of doing a seperate...
1
1279
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 the button...i have tried so many ways but didn't get the solutions till... i cant get click event for that...plz help me...
1
1032
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 id between " + (page - 1) * 10 + " and " + (page * 10 - 1) ; but it works when my 'id' have a correct sequence of number you know for example when you have 3 records with id 1,2,3 and when you delete second record after that you have 2 records...
0
7935
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, weíll explore What is ONU, What Is Router, ONU & Routerís main usage, and What is the difference between ONU and Router. Letís take a closer look ! Part I. Meaning of...
0
7871
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
7995
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8227
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5400
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3851
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3893
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1467
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1202
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.