Solved

Gridview.rows.count ASP.NET 2.0

Posted on 2007-12-05
6
6,032 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
ID: 20413699
ds.Tables(0).Rows.Count
0
 
LVL 7

Expert Comment

by:nisarkhan
ID: 20413713
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
ID: 20413840
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 7

Expert Comment

by:nisarkhan
ID: 20414166
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
ID: 20414179
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
ID: 31412920
Thanks man, it was hell:)
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

828 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