displaying number of results found ???

  • Thread starter Thread starter Tim T
  • Start date Start date
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
 
....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#)
 
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
 
....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
 
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
 
Back
Top