473,398 Members | 2,404 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

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 3729
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
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
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
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
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
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...

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.