Celebrate National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Return total number of records from a paged gridview

Posted on 2007-11-28
5
Medium Priority
?
1,223 Views
Last Modified: 2009-10-26
hi, ive got a gridview and im usiging paging. I can get the total number of records in the gridview
in the selected event of the objectdatasource :
CType(e.ReturnValue, DataTable).Rows.Count)

ive got a textbox where the user can filter a value from the grid. Im using the FilterExpression method of the objectdatasource. But i cannot get the records returned by the filter.
Any ideas????

thanks!
0
Comment
Question by:arcross
[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
5 Comments
 
LVL 7

Expert Comment

by:nisarkhan
ID: 20366874
myGridView.Rows.Count
0
 
LVL 7

Expert Comment

by:nisarkhan
ID: 20366883
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
0
 
LVL 7

Expert Comment

by:nisarkhan
ID: 20366903
other way of doing is:

// 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
 
LVL 8

Author Comment

by:arcross
ID: 20372369
hi nisarkhan,
If  I use gridview.rows.count. It will show me only the records for the page of the grid Im in. I want the total number of records after ive filtered using the .ExpresionFilter method of the Objectdatasource. I can get the total records using "CType(e.ReturnValue, DataTable).Rows.Count)"

but that doesnt gave me the records filtered.

any ideas?
0
 
LVL 7

Accepted Solution

by:
nisarkhan earned 1500 total points
ID: 20375049
>>>If  I use gridview.rows.count. It will show me only the records for the page of the grid

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

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

In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

730 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