Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Gridview.rows.count ASP.NET 2.0

Posted on 2007-12-05
6
Medium Priority
?
6,080 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Suggested Courses

810 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