Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Return total number of records from a paged gridview

Posted on 2007-11-28
5
Medium Priority
?
1,225 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
  • 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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Screencast - Getting to Know the Pipeline

926 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