Solved

Gridview.rows.count ASP.NET 2.0

Posted on 2007-12-05
6
5,999 Views
Last Modified: 2013-11-07
Ok, I have Gridview.Rows.Count to count my results. The problem is this: I have paging enabled... Where only the first 20 results are displayed per page. So there's possibly 8 pages of data (160-180) results but it only displays it found "20 results" for a textbox I have set up. How do I fix this? Thanks, Chris.
0
Comment
Question by:jumpstart0321
  • 4
  • 2
6 Comments
 
LVL 7

Expert Comment

by:nisarkhan
Comment Utility
ds.Tables(0).Rows.Count
0
 
LVL 7

Expert Comment

by:nisarkhan
Comment Utility
if you need all records then you need to use the ReturnValue of the ObjectDataSourceStatusEventArgs or
SqlDataSourceStatusEventArgs while handling the datasource's Selected event.
Look at this sample for the code

http://www.webswapp.com/codesamples/aspnet20/dropdownlist_gridview/default.aspx


try this.

// If your datasource is DataSet

DataSet ds=new DataSet();

ds=GetRecords(); // Retrieveing records from database

lblRecords.Text=ds.Tables[0].Rows.Count; // this is your label displaying total records
Gridview1.DataSource=ds;

Gridview1.DataBind();


0
 

Author Comment

by:jumpstart0321
Comment Utility
Ok, here's what I have:
A Gridview1 on my Default.aspx and a
SqlDataSource1 using a dataset.
All of this being made in the gui with an exception to the SQLDataSource Select query.
Considering the dataset isn't specifically declared in code, how do I reference the dataset if I never even gave it a name?
I have the gridview automatically populated on the Page_load event by declaring the select statement based on whatever is in the QueryString results.
I don't want to re-call the SELECT statement, because I would then have double the processing time which I can't afford. Thanks, Chris.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
LVL 7

Expert Comment

by:nisarkhan
Comment Utility
here is answer that you are looking for ..

http://fredrik.nsquared2.com/viewpost.aspx?PostID=336
0
 
LVL 7

Accepted Solution

by:
nisarkhan earned 500 total points
Comment Utility
if the above did not help you then you can have this

If sqldatasource.datasourcemode=dataset then

        Dim dr As Object
        dr = SqlDataSource1.Select(New System.Web.UI.DataSourceSelectArguments)
        MsgBox(dr.count)

But if datasourcemode=datareader, then the only way to find out is to scroll to the eof.
0
 

Author Closing Comment

by:jumpstart0321
Comment Utility
Thanks man, it was hell:)
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now