How to access all rows in GridView?

G

Guest

Hi All,
Can anybody please help me, how to access all rows in a grid view if the
paging is enabled?
If gridview contains 100 rows and pagecount=10, then in the gridview.rows
collection, i'm getting only those 10 rows which are displayed on the screen.
But i want to access all the 100 rows in the code.

Thanks in advance
 
B

bpd

How are you binding the data to the gridview - DataSet, DataSource,
ObjectSource, etc.?
 
D

David Wier

If you're wanting to access and see all the rows at once, why do you need
paging enabled?
You could always have a button that turns paging on/off - to see all rows,
or not....that is, if you want to go back and forth
 
G

Guest

Hi David
Thanks for the reply.
I don't want to see all rows at once
Because Paging is a requirement for my application.

One of the gridview column is editable.
I'm having a text box as a template field in that column, where user enters
some numeric value.
After entering the data in all rows user clicks Save button where i want to
save the data of gridview.

Thanks
Srinivas
 
G

Guest

I'm binding with a datatable.
I have an editable text box field also in the grid view.
while saving, again i need to get all the values entered in the editable
textboxes.

Thanks
 
M

miladhatam

hi
i think you must connect to your database instead of connecting to your
gridview
and insert it to an array
for eg= dataset.Table[0].Rows.ItemArray[j].ToString
 
G

Guest

Hi,
Thanks for the reply.
My problem is in accessing the values of each editable text box within the
grid view.
When the paging is enabled, i'm not able to access all the rows.

I will give you an example here.
I'm having a table with 3 columns OriginCity,DestinationCity and fare.
Now i have a gridview where i binded all these columns and i have one more
editable column where user can enter number of passengers.After entering the
values if user clicks save i need to calculate the total fare by (fare*no.of
passengers) and store it in DB. So while calculating the total fare i have to
access the gridview rows to get the total number of passengers.Paging should
be enabled.

Hope this helps you to understand the problem.

Thanks
 
B

bruce barker

they don't exist. the grid is just a window to bound object. you need to
go to the object source to get the other rows.

-- bruce (sqlwork.com)
 
B

bruce barker

unless you want to send all the table data to the browser in viewstate
(in which case you might as well turn off paging), you need to save the
original table data on the server side.

in your case you should turn off viewstate, save the table in session,
and the page number, then on postback rebind the table to the grid in
oninit.

-- bruce (sqlwork.com)
Hi,
Thanks for the reply.
My problem is in accessing the values of each editable text box within the
grid view.
When the paging is enabled, i'm not able to access all the rows.

I will give you an example here.
I'm having a table with 3 columns OriginCity,DestinationCity and fare.
Now i have a gridview where i binded all these columns and i have one more
editable column where user can enter number of passengers.After entering the
values if user clicks save i need to calculate the total fare by (fare*no.of
passengers) and store it in DB. So while calculating the total fare i have to
access the gridview rows to get the total number of passengers.Paging should
be enabled.

Hope this helps you to understand the problem.

Thanks

hi
i think you must connect to your database instead of connecting to your
gridview
and insert it to an array
for eg= dataset.Table[0].Rows.ItemArray[j].ToString
 
M

miladhatam

srinivas äæÔÊå ÇÓÊ:
Hi,
Thanks for the reply.
My problem is in accessing the values of each editable text box within the
grid view.
When the paging is enabled, i'm not able to access all the rows.

I will give you an example here.
I'm having a table with 3 columns OriginCity,DestinationCity and fare.
Now i have a gridview where i binded all these columns and i have one more
editable column where user can enter number of passengers.After entering the
values if user clicks save i need to calculate the total fare by (fare*no..of
passengers) and store it in DB. So while calculating the total fare i have to
access the gridview rows to get the total number of passengers.Paging should
be enabled.

Hope this helps you to understand the problem.

Thanks

hi
i think you must connect to your database instead of connecting to your
gridview
and insert it to an array
for eg= dataset.Table[0].Rows.ItemArray[j].ToString

i think you can use the sql command to do this work
but i have an idea
insert 2 gridviews to page and enable paging of one of them
then assign the visible of the gridview "false" that isnot enabled
paging of it
then you can use the information of gridview 2
ofcourse this way isnot professional
i hope that helps
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top