473,714 Members | 2,552 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Number of rows returned from ObjectDataSourc e.FilterExpress ion

How can I find how many rows are returned from the DataView generated by
FilterExpressio n on an ObjectDataSourc e?

I can get the number of rows in the underlying datatable by using:

protected void mydataSource_Se lected(object sender,
ObjectDataSourc eStatusEventArg s e)
{
numrows = ((DataTable) e.ReturnValue). Rows.Count;
}

But I can't get access to the dataview used by FilterExpressio n. It's not
((DataTable) e.ReturnValue). DefaultView

Thanks,

John
Mar 15 '06 #1
4 10238
e.ReturnValue should be of type DataView

Mar 16 '06 #2
I double checked, e.ReturnValue is a strongly typed datatable, not a
dataview.

I found that calling objDataSource.S elect() returns a dataview with the
filter applied, *but* this seems to result in a double call with the built
in databinding - unless you turn caching on.

Any ideas how to avoid the double call?

John

"Manu" <ma******@gmail .com> wrote in message
news:11******** *************@p 10g2000cwp.goog legroups.com...
e.ReturnValue should be of type DataView

Mar 18 '06 #3
This seems to work, but it's a bit clunky:

If the only way to get the dataview is to call objDataSource.S elect(), we
need to prevent the automatic databinding, otherwise a second SQL call will
result. I did the following in Page_PreRender:

DataView dv = myDataSource.Se lect() as DataView;
myDataSource.Da taSourceID = null; // break the auto-binding
amyDataSource.D ataSource = dv; // allow it to respond to manual
binding
DataBind();

This results in only one call to the SQL, and a dataview you can work with.

It would be so much better if this was made available in
ObjectDataSourc e.Selected

John

"John" <jo**@nowhere.c om> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
I double checked, e.ReturnValue is a strongly typed datatable, not a
dataview.

I found that calling objDataSource.S elect() returns a dataview with the
filter applied, *but* this seems to result in a double call with the built
in databinding - unless you turn caching on.

Any ideas how to avoid the double call?

John

Mar 18 '06 #4
But changing the binding from GridView.DataSo urceID to DataSource seems to
break sorting.

Ho hum.

I'll have to go back to caching the result for a couple of seconds between
the two calls to ObjectDataSourc e.Select() (my manual call, then the
automatic databinding one).

There must be a better way!!!

John

"John" <jo**@nowhere.c om> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
This seems to work, but it's a bit clunky:

If the only way to get the dataview is to call objDataSource.S elect(), we
need to prevent the automatic databinding, otherwise a second SQL call
will result. I did the following in Page_PreRender:

DataView dv = myDataSource.Se lect() as DataView;
myDataSource.Da taSourceID = null; // break the auto-binding
myDataSource.Da taSource = dv; // allow it to respond to binding
without calling Select() again

Mar 18 '06 #5

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

Similar topics

0
1937
by: Chris E | last post by:
Hi, I need to print a message when the number of rows returned from repeating groups is > 3. How is this best done? I have two repeating groups filtered to display only 3 rows. When either one returns more than 3 rows, I need my text message to print. Both repeating groups are using the same table. Different data is being displayed. I'm using reports 6i.
6
3004
by: yoohanman | last post by:
Hi, I have a select statment that correctly returns zero rows at times. I would like to be able to return the value 0 (a single row with the value 0) whenever the logic returns zero rows. something like this If no.of.rows.returned = 0 then output 0
7
12088
by: Egor Shipovalov | last post by:
I'm implementing paging through search results using cursors. Is there a better way to know total number of rows under a cursor than running a separate COUNT(*) query? I think PostgreSQL is bound to know this number after the first FETCH, isn't it? On a side note, why queries using LIMIT are SO terribly slow, compared to cursors and sometimes even ones without LIMIT? Shouldn't LIMIT be internally implemented using cursor mechanism then?...
1
13446
by: BF | last post by:
Hello, I am trying to find out if there is a way to limit the number of rows returned when a cursor is opened. I am using DB2 version 7 on z/OS. The SELECT statement in my DECLARE CURSOR statement could potentially return 400,000+ rows, but I really only want the first 15 records found. I can put a lower-bound (col >= "xxx") in the WHERE clause but cannot specify an upper-bound (i.e. AND col <= "yyy"); therefore, depending on the value...
2
6622
by: AnnieLab | last post by:
In Oracle you can restrict the number of rows returned by specifying 'WHERE ROWNUM < 10'. Can you do this in DB2 as well?
3
14137
by: Juan | last post by:
how to get number of rows returned by a SqlDataReader without having to scroll it?
4
14392
by: Chris Tremblay | last post by:
I am trying to figure out how to go about retrieving the number of results returned from my queries in SQL server from VB.NET without using a the Select Count(*) query. The method that I was using was the following: Take the query that I am executing, copy the query and turn it into a count query, run the count query, then execute the original query. The reason for this is so that I can implememt public paging on my website. The...
0
1075
by: John A Grandy | last post by:
In ASP.NET 2.0 , does the ObjectDataSource provide a method or property to return the number of rows returned ?
4
1543
by: esmith2112 | last post by:
I have a situation that I can't explain. Boiled down to its essence, I have a query of the form SELECT A.COL1, A.COL2, B.COL1 FROM A LEFT JOIN B ON A.KEY = B.KEY This query produces 5383 rows of output. Because B.COL1 was defined as VARCHAR(2000), it was making my ouput file too hard to browse so I eliminated it from the select clause.
2
4739
by: yuva17raj | last post by:
hi i am using the select query with group by, so that i am getting records with more than one column so that i need to calculate the number of rows returned by the query for example with my select ..group by i get the result as follows userid count(*) 101 12 105 13 100 10 34 6 but i need to calculate number of rows returned so that my...
0
8707
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,...
0
9314
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9074
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
7953
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6634
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4464
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
4725
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3158
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 we have to send another system
3
2110
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.