Solved

Return total number of records from a paged gridview

Posted on 2007-11-28
5
1,222 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 500 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

623 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