?
Solved

Gridview.rows.count ASP.NET 2.0

Posted on 2007-12-05
6
Medium Priority
?
6,059 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get your Disaster Recovery as a Service basics

Disaster Recovery as a Service is one go-to solution that revolutionizes DR planning. Implementing DRaaS could be an efficient process, easily accessible to non-DR experts. Learn about monitoring, testing, executing failovers and failbacks to ensure a "healthy" DR environment.

 
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 2000 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

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

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

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses

770 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