displaying number of results found ???

T

Tim T

Hi,

I have a stored procedure executing a search and an asp.net page displaying
the results in a datagrid. The datagrid has paging on it, I am using Visual
Studio.NET and can't see any option to show the number of results found.
Is there an easy way to add this to the top of the datagrid, along with the
total number of pages ie:

67 resuts found
page 1 of 7 [1 2 3 4 5 6 7] (where the numbers in [] are hyperlinks to that
page)
or page 4 of 7 [<back next>]

using C#, but if you post VB.NET code i'll be able to work it out

any help appreciated.

Thanks

Tim
 
R

Raphael Iloh

....to get the total number of records found, you could do either
1. datagrid.Items.Count or
2. dataview.Count (if you are using a DataView object. You can follow this
premise for other datasources that implement the IEnumerable interface.)

To show custom pager style, you'd need to override the default pager style
in the datagrid control. You can do this by writing an event listener for
the OnItemCreated event of the datagrid control.

Regards, Raphael Iloh
MCAD (C#)
 
T

Tim T

Thanks for your reply Raphael,
but all datagrid.Items.Count does is return the number of items in the
datagrid on that page, it 10 if the page size is 10. I need something that
returns the total number of results found, I'm sure this is available and
easy, I'm just not clued up and dont know how.

Anyone know??

Thanks
Tim

Raphael Iloh said:
...to get the total number of records found, you could do either
1. datagrid.Items.Count or
2. dataview.Count (if you are using a DataView object. You can follow this
premise for other datasources that implement the IEnumerable interface.)

To show custom pager style, you'd need to override the default pager style
in the datagrid control. You can do this by writing an event listener for
the OnItemCreated event of the datagrid control.

Regards, Raphael Iloh
MCAD (C#)


Tim T said:
Hi,

I have a stored procedure executing a search and an asp.net page displaying
the results in a datagrid. The datagrid has paging on it, I am using Visual
Studio.NET and can't see any option to show the number of results found.
Is there an easy way to add this to the top of the datagrid, along with the
total number of pages ie:

67 resuts found
page 1 of 7 [1 2 3 4 5 6 7] (where the numbers in [] are hyperlinks to that
page)
or page 4 of 7 [<back next>]

using C#, but if you post VB.NET code i'll be able to work it out

any help appreciated.

Thanks

Tim
 
R

Raphael Iloh

....Tim, your assumption isn't right; the datagrid.Items.Count property
actually returns the total number of items contained in the datasource that
the datagrid is bound to and not the page size of the datagrid (see
http://msdn.microsoft.com/library/d...emwebuiwebcontrolsdatagridclassitemstopic.asp).
Alternatively, you can obtain the number of objects contained in the
datasource, directly from the datasource; what r u using as your datasource;
dataview, dataset, datatable? These datasources provide a property by which
you can obtain the number of objects contained in them; for dataview it's
dataview.Count; for dataset it's dataset.Tables.Count, etc.

Regards, Raphael
MCAD(C#)

Tim T said:
Thanks for your reply Raphael,
but all datagrid.Items.Count does is return the number of items in the
datagrid on that page, it 10 if the page size is 10. I need something that
returns the total number of results found, I'm sure this is available and
easy, I'm just not clued up and dont know how.

Anyone know??

Thanks
Tim

Raphael Iloh said:
...to get the total number of records found, you could do either
1. datagrid.Items.Count or
2. dataview.Count (if you are using a DataView object. You can follow this
premise for other datasources that implement the IEnumerable interface.)

To show custom pager style, you'd need to override the default pager style
in the datagrid control. You can do this by writing an event listener for
the OnItemCreated event of the datagrid control.

Regards, Raphael Iloh
MCAD (C#)


Tim T said:
Hi,

I have a stored procedure executing a search and an asp.net page displaying
the results in a datagrid. The datagrid has paging on it, I am using Visual
Studio.NET and can't see any option to show the number of results found.
Is there an easy way to add this to the top of the datagrid, along
with
the
total number of pages ie:

67 resuts found
page 1 of 7 [1 2 3 4 5 6 7] (where the numbers in [] are hyperlinks
to
that
page)
or page 4 of 7 [<back next>]

using C#, but if you post VB.NET code i'll be able to work it out

any help appreciated.

Thanks

Tim
 
T

Tim T

Thanks Raphael

I'm using a dataset.
resultsFound.Text = dataSet1.Tables[0].Rows.Count.ToString();

works perfectly. thanks!

datagrid1.Items.Count returns the number of items within the datagrid on
that page ie it always returns 10 (at most when page size is set to 10)

Tim


Raphael Iloh said:
...Tim, your assumption isn't right; the datagrid.Items.Count property
actually returns the total number of items contained in the datasource that
the datagrid is bound to and not the page size of the datagrid (see
http://msdn.microsoft.com/library/d...emwebuiwebcontrolsdatagridclassitemstopic.asp).
Alternatively, you can obtain the number of objects contained in the
datasource, directly from the datasource; what r u using as your datasource;
dataview, dataset, datatable? These datasources provide a property by which
you can obtain the number of objects contained in them; for dataview it's
dataview.Count; for dataset it's dataset.Tables.Count, etc.

Regards, Raphael
MCAD(C#)

Tim T said:
Thanks for your reply Raphael,
but all datagrid.Items.Count does is return the number of items in the
datagrid on that page, it 10 if the page size is 10. I need something that
returns the total number of results found, I'm sure this is available and
easy, I'm just not clued up and dont know how.

Anyone know??

Thanks
Tim

Raphael Iloh said:
...to get the total number of records found, you could do either
1. datagrid.Items.Count or
2. dataview.Count (if you are using a DataView object. You can follow this
premise for other datasources that implement the IEnumerable interface.)

To show custom pager style, you'd need to override the default pager style
in the datagrid control. You can do this by writing an event listener for
the OnItemCreated event of the datagrid control.

Regards, Raphael Iloh
MCAD (C#)


Hi,

I have a stored procedure executing a search and an asp.net page
displaying
the results in a datagrid. The datagrid has paging on it, I am using
Visual
Studio.NET and can't see any option to show the number of results found.
Is there an easy way to add this to the top of the datagrid, along with
the
total number of pages ie:

67 resuts found
page 1 of 7 [1 2 3 4 5 6 7] (where the numbers in [] are hyperlinks to
that
page)
or page 4 of 7 [<back next>]

using C#, but if you post VB.NET code i'll be able to work it out

any help appreciated.

Thanks

Tim
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top