473,322 Members | 1,496 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Number of rows returned from ObjectDataSource.FilterExpression

How can I find how many rows are returned from the DataView generated by
FilterExpression on an ObjectDataSource?

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

protected void mydataSource_Selected(object sender,
ObjectDataSourceStatusEventArgs e)
{
numrows = ((DataTable) e.ReturnValue).Rows.Count;
}

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

Thanks,

John
Mar 15 '06 #1
4 10220
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.Select() 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*********************@p10g2000cwp.googlegro ups.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.Select(), we
need to prevent the automatic databinding, otherwise a second SQL call will
result. I did the following in Page_PreRender:

DataView dv = myDataSource.Select() as DataView;
myDataSource.DataSourceID = null; // break the auto-binding
amyDataSource.DataSource = 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
ObjectDataSource.Selected

John

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

I found that calling objDataSource.Select() 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.DataSourceID 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 ObjectDataSource.Select() (my manual call, then the
automatic databinding one).

There must be a better way!!!

John

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

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

DataView dv = myDataSource.Select() as DataView;
myDataSource.DataSourceID = null; // break the auto-binding
myDataSource.DataSource = 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
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...
6
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. ...
7
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...
1
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...
2
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
by: Juan | last post by:
how to get number of rows returned by a SqlDataReader without having to scroll it?
4
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...
0
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
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...
2
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...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.