473,472 Members | 1,831 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

datasource.recordcount? How to obtain this?

How do I (or is this even possible) get the total number of records from a
datasource control in ASP.NET 2.0?

I’ve messed around with getting the row count from the grid that the
datasource is bound to, but, that control uses paging and it appears that the
count is only for the page that is in view.

I’m guessing that this is pretty simple, but, I’m flummoxed.

Thanks for any help you can offer.

B
Feb 9 '06 #1
7 1642
Depending on the DataSource object that you used and the type of the data
that it returns you would have to modify a bit the code. But in general you
can handle the Selected event of the DataSource which passes to you an
Eventargs that has an AffectedRows property. For a sample code you may
refer to this demo:
http://www.webswapp.com/codesamples/...list_gridview/

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"bernadou" wrote:
How do I (or is this even possible) get the total number of records from a
datasource control in ASP.NET 2.0?

I’ve messed around with getting the row count from the grid that the
datasource is bound to, but, that control uses paging and it appears that the
count is only for the page that is in view.

I’m guessing that this is pretty simple, but, I’m flummoxed.

Thanks for any help you can offer.

B

Feb 9 '06 #2
It is actually the ((DataView)e.ReturnValue).Count, not the e.AffectedRow.
"Phillip Williams" wrote:
Depending on the DataSource object that you used and the type of the data
that it returns you would have to modify a bit the code. But in general you
can handle the Selected event of the DataSource which passes to you an
Eventargs that has an AffectedRows property. For a sample code you may
refer to this demo:
http://www.webswapp.com/codesamples/...list_gridview/

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"bernadou" wrote:
How do I (or is this even possible) get the total number of records from a
datasource control in ASP.NET 2.0?

I’ve messed around with getting the row count from the grid that the
datasource is bound to, but, that control uses paging and it appears that the
count is only for the page that is in view.

I’m guessing that this is pretty simple, but, I’m flummoxed.

Thanks for any help you can offer.

B

Feb 9 '06 #3
Phillip,
You blow my mind. Is there anything you don't know or haven't worked
with!?!

Thanks once again. The e.AffectedRows worked (at least so far). I tried
working with the other line of code, but, I must admit that I don't
understand the code constructiion. Should you have the time and inclination
to answer my followup I'd appreciate it, but, it is more curiosity for me at
this point rather than an urgent need. So...

My data grid is "GridVew1"
The code: ((GridView1)e.ReturnValue).Count doesn't work when I put it in the
Page_load event. My guess it that since I'm using. I'm don't think I
understand it enough to try to work with it too much. So...
What does this do? "( ).count" and what does this "(DataGrid)e.ReturnValue"
do?

Thanks as always for your straight to the point and spot on responses.

B

"Phillip Williams" wrote:
It is actually the ((DataView)e.ReturnValue).Count, not the e.AffectedRow.
"Phillip Williams" wrote:
Depending on the DataSource object that you used and the type of the data
that it returns you would have to modify a bit the code. But in general you
can handle the Selected event of the DataSource which passes to you an
Eventargs that has an AffectedRows property. For a sample code you may
refer to this demo:
http://www.webswapp.com/codesamples/...list_gridview/

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"bernadou" wrote:
How do I (or is this even possible) get the total number of records from a
datasource control in ASP.NET 2.0?

I’ve messed around with getting the row count from the grid that the
datasource is bound to, but, that control uses paging and it appears that the
count is only for the page that is in view.

I’m guessing that this is pretty simple, but, I’m flummoxed.

Thanks for any help you can offer.

B

Feb 9 '06 #4
Phillip,
You blow my mind. Is there anything you don't know or haven't worked
with!?!

Thanks once again. The e.AffectedRows worked (at least so far). I tried
working with the other line of code, but, I must admit that I don't
understand the code constructiion. Should you have the time and inclination
to answer my followup I'd appreciate it, but, it is more curiosity for me at
this point rather than an urgent need. So...

My data grid is "GridVew1"
The code: ((GridView1)e.ReturnValue).Count doesn't work when I put it in the
Page_load event. My guess it that since I'm using. I'm don't think I
understand it enough to try to work with it too much. So...
What does this do? "( ).count" and what does this "(DataGrid)e.ReturnValue"
do?

Thanks as always for your straight to the point and spot on responses.

B

"Phillip Williams" wrote:
It is actually the ((DataView)e.ReturnValue).Count, not the e.AffectedRow.
"Phillip Williams" wrote:
Depending on the DataSource object that you used and the type of the data
that it returns you would have to modify a bit the code. But in general you
can handle the Selected event of the DataSource which passes to you an
Eventargs that has an AffectedRows property. For a sample code you may
refer to this demo:
http://www.webswapp.com/codesamples/...list_gridview/

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"bernadou" wrote:
How do I (or is this even possible) get the total number of records from a
datasource control in ASP.NET 2.0?

I’ve messed around with getting the row count from the grid that the
datasource is bound to, but, that control uses paging and it appears that the
count is only for the page that is in view.

I’m guessing that this is pretty simple, but, I’m flummoxed.

Thanks for any help you can offer.

B

Feb 9 '06 #5
Depending on the type of DataSource object that you use the AffectedRows
property of the eventargs might work or not. For the
ObjectDataSourceStatusEventArgs it will work:
http://msdn2.microsoft.com/en-us/lib...ectedrows.aspx

For the SqlDataSourceEventArgs, it will work if you do not have this
DataSourceMode="DataReader" in the markup, otherwise you will get 0
http://msdn2.microsoft.com/en-us/lib...ectedrows.aspx

Regarding your question:

The code: ((DataView)e.ReturnValue) was actually a typo. My apology. I
sort of relied on you viewing the demo. It should have been
(DataView)e.ReturnValue as in the demo link I provided. This code should not
be placed in the method that handles the Page.Load. Notice its place in the
demo whose link I gave to you:
http://www.webswapp.com/codesamples/...list_gridview/

void odsCustomersList_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
//notice that this datasource returns a DataView
lblCount1.Text = "Total Record count in the dropdownlist above= "
+ ((DataView)e.ReturnValue).Count.ToString();
}

The explanation for that construct is:
((DataView)e.ReturnValue).Count would cast the returned value of the object
datasource to a DataView then gets the record count from the DataView.

My apology for the typo that caused this confusion.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"bernadou" wrote:
Phillip,
You blow my mind. Is there anything you don't know or haven't worked
with!?!

Thanks once again. The e.AffectedRows worked (at least so far). I tried
working with the other line of code, but, I must admit that I don't
understand the code constructiion. Should you have the time and inclination
to answer my followup I'd appreciate it, but, it is more curiosity for me at
this point rather than an urgent need. So...

My data grid is "GridVew1"
The code: ((GridView1)e.ReturnValue).Count doesn't work when I put it in the
Page_load event. My guess it that since I'm using. I'm don't think I
understand it enough to try to work with it too much. So...
What does this do? "( ).count" and what does this "(DataGrid)e.ReturnValue"
do?

Thanks as always for your straight to the point and spot on responses.

B

"Phillip Williams" wrote:
It is actually the ((DataView)e.ReturnValue).Count, not the e.AffectedRow.
"Phillip Williams" wrote:
Depending on the DataSource object that you used and the type of the data
that it returns you would have to modify a bit the code. But in general you
can handle the Selected event of the DataSource which passes to you an
Eventargs that has an AffectedRows property. For a sample code you may
refer to this demo:
http://www.webswapp.com/codesamples/...list_gridview/

--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"bernadou" wrote:

> How do I (or is this even possible) get the total number of records from a
> datasource control in ASP.NET 2.0?
>
> I’ve messed around with getting the row count from the grid that the
> datasource is bound to, but, that control uses paging and it appears that the
> count is only for the page that is in view.
>
> I’m guessing that this is pretty simple, but, I’m flummoxed.
>
> Thanks for any help you can offer.
>
> B

Feb 9 '06 #6
Sorry, you are correct. I should have checked out the demo first. Thanks
for clarifying the code. Makes sense.

Ignore my duplicate response, not sure how that happened.

Thanks!
B

"Phillip Williams" wrote:
Depending on the type of DataSource object that you use the AffectedRows
property of the eventargs might work or not. For the
ObjectDataSourceStatusEventArgs it will work:
http://msdn2.microsoft.com/en-us/lib...ectedrows.aspx

For the SqlDataSourceEventArgs, it will work if you do not have this
DataSourceMode="DataReader" in the markup, otherwise you will get 0
http://msdn2.microsoft.com/en-us/lib...ectedrows.aspx

Regarding your question:

The code: ((DataView)e.ReturnValue) was actually a typo. My apology. I
sort of relied on you viewing the demo. It should have been
(DataView)e.ReturnValue as in the demo link I provided. This code should not
be placed in the method that handles the Page.Load. Notice its place in the
demo whose link I gave to you:
http://www.webswapp.com/codesamples/...list_gridview/

void odsCustomersList_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
//notice that this datasource returns a DataView
lblCount1.Text = "Total Record count in the dropdownlist above= "
+ ((DataView)e.ReturnValue).Count.ToString();
}

The explanation for that construct is:
((DataView)e.ReturnValue).Count would cast the returned value of the object
datasource to a DataView then gets the record count from the DataView.

My apology for the typo that caused this confusion.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"bernadou" wrote:
Phillip,
You blow my mind. Is there anything you don't know or haven't worked
with!?!

Thanks once again. The e.AffectedRows worked (at least so far). I tried
working with the other line of code, but, I must admit that I don't
understand the code constructiion. Should you have the time and inclination
to answer my followup I'd appreciate it, but, it is more curiosity for me at
this point rather than an urgent need. So...

My data grid is "GridVew1"
The code: ((GridView1)e.ReturnValue).Count doesn't work when I put it in the
Page_load event. My guess it that since I'm using. I'm don't think I
understand it enough to try to work with it too much. So...
What does this do? "( ).count" and what does this "(DataGrid)e.ReturnValue"
do?

Thanks as always for your straight to the point and spot on responses.

B

"Phillip Williams" wrote:
It is actually the ((DataView)e.ReturnValue).Count, not the e.AffectedRow.
"Phillip Williams" wrote:

> Depending on the DataSource object that you used and the type of the data
> that it returns you would have to modify a bit the code. But in general you
> can handle the Selected event of the DataSource which passes to you an
> Eventargs that has an AffectedRows property. For a sample code you may
> refer to this demo:
> http://www.webswapp.com/codesamples/...list_gridview/
>
> --
> HTH,
> Phillip Williams
> http://www.societopia.net
> http://www.webswapp.com
>
>
> "bernadou" wrote:
>
> > How do I (or is this even possible) get the total number of records from a
> > datasource control in ASP.NET 2.0?
> >
> > I’ve messed around with getting the row count from the grid that the
> > datasource is bound to, but, that control uses paging and it appears that the
> > count is only for the page that is in view.
> >
> > I’m guessing that this is pretty simple, but, I’m flummoxed.
> >
> > Thanks for any help you can offer.
> >
> > B

Feb 9 '06 #7
You are quite welcome.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"bernadou" wrote:
Sorry, you are correct. I should have checked out the demo first. Thanks
for clarifying the code. Makes sense.

Ignore my duplicate response, not sure how that happened.

Thanks!
B

"Phillip Williams" wrote:
Depending on the type of DataSource object that you use the AffectedRows
property of the eventargs might work or not. For the
ObjectDataSourceStatusEventArgs it will work:
http://msdn2.microsoft.com/en-us/lib...ectedrows.aspx

For the SqlDataSourceEventArgs, it will work if you do not have this
DataSourceMode="DataReader" in the markup, otherwise you will get 0
http://msdn2.microsoft.com/en-us/lib...ectedrows.aspx

Regarding your question:

The code: ((DataView)e.ReturnValue) was actually a typo. My apology. I
sort of relied on you viewing the demo. It should have been
(DataView)e.ReturnValue as in the demo link I provided. This code should not
be placed in the method that handles the Page.Load. Notice its place in the
demo whose link I gave to you:
http://www.webswapp.com/codesamples/...list_gridview/

void odsCustomersList_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
//notice that this datasource returns a DataView
lblCount1.Text = "Total Record count in the dropdownlist above= "
+ ((DataView)e.ReturnValue).Count.ToString();
}

The explanation for that construct is:
((DataView)e.ReturnValue).Count would cast the returned value of the object
datasource to a DataView then gets the record count from the DataView.

My apology for the typo that caused this confusion.
--
HTH,
Phillip Williams
http://www.societopia.net
http://www.webswapp.com
"bernadou" wrote:
Phillip,
You blow my mind. Is there anything you don't know or haven't worked
with!?!

Thanks once again. The e.AffectedRows worked (at least so far). I tried
working with the other line of code, but, I must admit that I don't
understand the code constructiion. Should you have the time and inclination
to answer my followup I'd appreciate it, but, it is more curiosity for me at
this point rather than an urgent need. So...

My data grid is "GridVew1"
The code: ((GridView1)e.ReturnValue).Count doesn't work when I put it in the
Page_load event. My guess it that since I'm using. I'm don't think I
understand it enough to try to work with it too much. So...
What does this do? "( ).count" and what does this "(DataGrid)e.ReturnValue"
do?

Thanks as always for your straight to the point and spot on responses.

B

"Phillip Williams" wrote:

> It is actually the ((DataView)e.ReturnValue).Count, not the e.AffectedRow.
>
>
> "Phillip Williams" wrote:
>
> > Depending on the DataSource object that you used and the type of the data
> > that it returns you would have to modify a bit the code. But in general you
> > can handle the Selected event of the DataSource which passes to you an
> > Eventargs that has an AffectedRows property. For a sample code you may
> > refer to this demo:
> > http://www.webswapp.com/codesamples/...list_gridview/
> >
> > --
> > HTH,
> > Phillip Williams
> > http://www.societopia.net
> > http://www.webswapp.com
> >
> >
> > "bernadou" wrote:
> >
> > > How do I (or is this even possible) get the total number of records from a
> > > datasource control in ASP.NET 2.0?
> > >
> > > I’ve messed around with getting the row count from the grid that the
> > > datasource is bound to, but, that control uses paging and it appears that the
> > > count is only for the page that is in view.
> > >
> > > I’m guessing that this is pretty simple, but, I’m flummoxed.
> > >
> > > Thanks for any help you can offer.
> > >
> > > B

Feb 9 '06 #8

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

Similar topics

2
by: Jeff Boyer | last post by:
Hello everyone, Can someone tell me why a ADO recordset.recordcount would return a -1? I have confirmed that it has records in it by writing some values to the screen. Why can't I count the...
0
by: Juan | last post by:
Do i have to loop trough a datagrid in order to find and select a row just being inserted in the dataset connected to the data grid? is there any event i can capture in the datagrid to obtain the...
12
by: scott | last post by:
In LISTING 2, I have a SPROC that returns a recordset and a recordcount in SQL QA. I can access the Recordset with no problem. How can I grab the Recordcount with ASP code at the same time I'm...
0
by: ghanley | last post by:
I have searched the web all day for a lead on this. I have found how to control the Graph object mut not the embedded excel unbound object frame. I am trying to chart the data below on one...
4
by: don.fleming | last post by:
Hi folks: Am doing a VBA SQL Select stmt with multiple rows found and not getting RecordCount > 1. I've verified there are multiple rows found by copying my SQL stmt from Debug window and pasting...
10
by: Robert | last post by:
How do you get an accurate count of the number of records returned from a query when using linked tables. I have an access 2003 database as a front end to another access 2003 database that...
2
by: shahiz | last post by:
basically im having null pointer exception //read an inputstream is = new DataInputStream(new FileInputStream("test.mpg")); loadBytes(is); //pass it as a datasource for the player public...
0
by: shahiz | last post by:
This the error i get when i try to run my program Error: Unable to realize com.sun.media.amovie.AMController@18b81e3 Basically i have a mediapanel class that initialize and play the media as...
2
by: cmrchs | last post by:
Hello, I have a GridView and an objectDataSource <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" AllowPaging="True" /> <asp:ObjectDataSource...
0
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,...
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...
1
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...
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,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
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 ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.