473,503 Members | 3,715 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Getting all the datagrid rows

Hi,

I have a datagrid which has many pages (10 rows per page)
and when I loop through the rows, I only get 10 rows (the
rows that are currently showed in the current page) How
can I get the total number of rows in all the pages?
Changing the current page and executing teh Databind()
method? Is there another way without having to query the
DB again?

Thanks in advance.

God Bless.
Jul 19 '05 #1
3 3730
Could you loop the grid's datasource instead?

Dim dv As New DataView()
Dim drv As DataRowView
Try
dv = CType(dgMyDataGrid.DataSource, DataView)
For Each drv In dv
' do my thing here
Console.WriteLine(CStr(drv(0)))
Next

Return True
Catch exc As Exception
MsgBox(exc.Message, MsgBoxStyle.Critical)
Finally
dv = Nothing
drv = Nothing
End Try
Jul 19 '05 #2
I was trying to avoid this, but it seems it's the only way
I have. One more question: Is the property DataSource
always available (after the method DataBind is called)? I
was trying to pass this property as a parameter to a
function to loop it, but it was set to nothing... Any
ideas?

Thanks in advance.
-----Original Message-----
Could you loop the grid's datasource instead?

Dim dv As New DataView()
Dim drv As DataRowView
Try
dv = CType(dgMyDataGrid.DataSource, DataView) For Each drv In dv
' do my thing here
Console.WriteLine(CStr(drv(0)))
Next

Return True
Catch exc As Exception
MsgBox(exc.Message, MsgBoxStyle.Critical)
Finally
dv = Nothing
drv = Nothing
End Try
.

Jul 19 '05 #3
The .PageCount property of your datagrid will tell you how many pages
there are for the current RowCount setting.

So, 10 rows per page and 9 pages would be 91 - 100 records.

Is that any help?

You can also just run a quick SELECT COUNT query against your
datasource to get the number of records.
"Mario Vargas" <ma*********@viabcp.com> wrote in message news:<06****************************@phx.gbl>...
Hi,

I have a datagrid which has many pages (10 rows per page)
and when I loop through the rows, I only get 10 rows (the
rows that are currently showed in the current page) How
can I get the total number of rows in all the pages?
Changing the current page and executing teh Databind()
method? Is there another way without having to query the
DB again?

Thanks in advance.

God Bless.

Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
298
by: Mario Vargas | last post by:
Hi, I have a datagrid which has many pages (10 rows per page) and when I loop through the rows, I only get 10 rows (the rows that are currently showed in the current page) How can I get the...
2
2349
by: Red Green | last post by:
I have a form with a datagrid and a dataset bound to it. I want to launch a second form and pass it a value from whichever record the user has selected. I can't find an example anywhere that shows...
4
3469
by: kscdavefl | last post by:
I ahve a datagrid on a web form. I need to change the value in column 3 as follows. If the value in column 3 reads 0, I want to change it to read YES. How can I accomplish this task. ...
4
5334
by: Glenn Owens | last post by:
I have a DataGrid web control which I've dynamically populated with template columns to be used for bulk-editting. Generally, all of the columns are textbox and/or dropdownlist child controls. ...
0
1369
by: John Shum | last post by:
I prepare a UserControl that act as a lookup control, once the code is enter in the TextBox, the description will appear in another TextBox outside the UserControl of the same row in a DataGrid via...
4
2261
by: Jan Nielsen | last post by:
Hi all I'm a former Access developer who would like to implement a many-to-many relation in about the same way you do in Access: With a subform and a combo box. Is it possible to use a...
3
9880
by: | last post by:
I wrote a class in VB.NET to export the contents of a datagrid to Excel. It works perfectly on my machine, but it fails on my customers' PCs that have identical versions of Win XP (SP1) and Excel...
0
1505
by: Greg | last post by:
I've made a datagrid multiline (for anyone interested, I used an adaptation of the code at http://64.78.52.104/FAQ/WinForms/FAQ_c44c.asp). This has introduced a very serious issue: the vertical...
0
1786
by: rn5a | last post by:
All the rows in a DataGrid are accompanied by a CheckBox. When a user checks the rows & clicks a Button, the checked rows get deleted. For e.g. assume that the DataGrid displays 10 rows. A user...
0
7261
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,...
0
5559
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,...
1
4991
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4665
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
3158
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...
0
3147
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1492
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
721
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
369
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.