By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,426 Members | 3,407 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,426 IT Pros & Developers. It's quick & easy.

displaying number of results found ???

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
....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" <br*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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

Nov 18 '05 #2

P: n/a
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" <no****@hotmail.com> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
...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" <br*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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


Nov 18 '05 #3

P: n/a
....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/de...temstopic.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[i].Count, etc.

Regards, Raphael
MCAD(C#)

"Tim T" <br*********@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
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" <no****@hotmail.com> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
...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" <br*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
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



Nov 18 '05 #4

P: n/a
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" <no****@hotmail.com> wrote in message
news:uZ**************@TK2MSFTNGP10.phx.gbl...
...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/de...temstopic.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[i].Count, etc.

Regards, Raphael
MCAD(C#)

"Tim T" <br*********@hotmail.com> wrote in message
news:ON**************@TK2MSFTNGP09.phx.gbl...
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" <no****@hotmail.com> wrote in message
news:ud**************@TK2MSFTNGP12.phx.gbl...
...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" <br*********@hotmail.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
> 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
>
>



Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.