473,473 Members | 1,488 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Find total no. of records in a gridview

375 Contributor
hello
I am using a gridview to display records.
I have set page index for the grid.
I have populated the gridview.
After every 10 records I will move to the next page.
All these works fine.

Now I want to place total no. of records in the gridview in a label.
I tried to use page count but it gives ambigous result.

eg. I have say 68 records. So I will have 7 pages.
I want to place a label saying that I have 68 records and details are in the gridview.
But the page count says 70 records.
Kindly let me know how to find the "count of rows "populated in the gridview.

Regards
cmrhema
Aug 29 '07 #1
4 3916
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
hello
I am using a gridview to display records.
I have set page index for the grid.
I have populated the gridview.
After every 10 records I will move to the next page.
All these works fine.

Now I want to place total no. of records in the gridview in a label.
I tried to use page count but it gives ambigous result.

eg. I have say 70 records. So I will have 7 pages.
I want to place a label saying that I have 70 records and details are in the gridview.

Kindly let me know how to find the count of rows populated in the gridview.

Regards
cmrhema
try
Expand|Select|Wrap|Line Numbers
  1. this.gridview1.RowCount
Aug 29 '07 #2
mzmishra
390 Recognized Expert Contributor
"YourDataSet".Tables[0].Rows.Count.ToString()
Aug 29 '07 #3
cmrhema
375 Contributor
Thank you both for the prompt reply

Unfortunately, I did not make one important point clear.

The catch is I have not attached to any database.

The customers will be filling the datas in the grid for which the values will be stored in temporary datatable(which will not be inserted in a database at present).

now when the customer clicks the submit button, All the records in the gridview will be updated.

For this I should know how many records he has entered so that I can place a for loop and insert the respective datas.

After inserting 10 records the grid view will move to the next page
Assume the customer enters two more records
So the count is 12 and page count is 2.

But the moment we use page count it gives 2*10=20 records.

But the answer is 12 not 20.
I hope I made myself clear
Aug 29 '07 #4
Shashi Sadasivan
1,435 Recognized Expert Top Contributor
Thank you both for the prompt reply

Unfortunately, I did not make one important point clear.

The catch is I have not attached to any database.

The customers will be filling the datas in the grid for which the values will be stored in temporary datatable(which will not be inserted in a database at present).

now when the customer clicks the submit button, All the records in the gridview will be updated.

For this I should know how many records he has entered so that I can place a for loop and insert the respective datas.

After inserting 10 records the grid view will move to the next page
Assume the customer enters two more records
So the count is 12 and page count is 2.

But the moment we use page count it gives 2*10=20 records.

But the answer is 12 not 20.
I hope I made myself clear
Are you keeping a track of the page number the user is in?
If yes then you would need
Expand|Select|Wrap|Line Numbers
  1. numRecords = 10 * (current_page_number -1) + (gridView1.RowCount);
Please also consider the reply from mzmishra..you will the total number of rows entered by the user
Aug 29 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Amelyan | last post by:
I need to get the total number of items/records returned into GridView. If I just do myGridView.Rows.Count, then it just returns me the total number of items on the page. But if I have, 10...
0
by: jimmy6509 | last post by:
Hello all, asp.net 2.0, VB. Have a simple question that I hope someone can help me with. gridview -> queries for a filtered recordset, example purchase orders attributed to a specific...
1
by: Marc | last post by:
Hi, I made a detailsview for inserting records. I also made a gridview for editing and deleting the same records. The keyfield is an autonumbering field in Access (pcnr). My problem is: I can...
2
by: msch-prv | last post by:
Hi, I have a paged gridview (Apts_grd) tied to an Access DataSource (Apts_srcGrd). How do I get the total number of data records returned by the query? The following shows only the number of...
5
by: Randy Smith | last post by:
Hi ALL, I wonder if anyone has been using n-tier to bind to a GridView control by using the ObjectDataSource. This is our first OOP web application, and we have no tables. Right now we are...
0
by: Hooman | last post by:
Hi, I have the same problem, actually i had two problems: I wanted to show the row index in my girdview for each row and then i want to show the total records on the top of the page. The...
4
by: =?Utf-8?B?cm9kY2hhcg==?= | last post by:
hey all, i have a gridview of records and i'm trying to display the total pages with 10 records per page. int totalpages; totalpages = 1148 / 10; totalpages = 114; there's actually 115...
1
by: Craig Buchanan | last post by:
Is there a way to determine the total number of records that will be bound to a GridView during the row's dataBound event? considering all of the types of data objects that can be bound to the...
0
parshupooja
by: parshupooja | last post by:
Hey All, I have where I want to do some manipulations and show in other column but unable to find their values in RowDatabound event even though I have two records in gridview <asp:GridView...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.