C# Gridview

I want to pass Gridview values across pages. Could you please provide me the syntax for this?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you plz elaborate on what exactly you want to pass across pages from the gridview?
Hi, Are you talking from windows forms aspect or fror ASP.NET pages. I guess you are talking about paging. Some of the links of help are

.NET Paging
MRManthaniAuthor Commented:
I have some labels placed in a grdiview. I'm doing some price calculations and displayed those values in the labels. Now, I need to use those price values in the next page and perform some other calculation.
Hope you understand what I  meant.

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Sure, you have two options with you:

Before explaining anything else, I assume you will be having a button/linkbutton on the
page pressing which you are redirecting user to different page.

So on the click of this button, in the server side event handler, we have to write our
code of how are are going to pass the variables to the next page.

Now the options:

1. Put variable values in session (more secure) and access them from session on the next page.
2. Put variable values appended in the query string and access query string from the next page(less secure)

let me explain the secure way (session)

say you have values in label1 and label2 which you want to pass to page2 from page1,

on the linkbutton's click event on page 1, you do this


now on page2's code in the page_load event, get them back like this:



if not ispostback then

Int64 pricevarA = Convert.ToInt64(Session["priceVarA"]);
Int64 pricevarB = Convert.ToInt64(Session["priceVarB"]);


end if

Hope it helped.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial

And if you are using a dataset to populate the gridview, you can store the dataset itself in session. Then it is possible for you to access the object itself and retrieve its values from another page.

Abh4IT, Storing dataset in session will consume lot of resources and should be the last resort. Session is maintained on both sides and should be used as efficiently as possible.
Yes I agree, thatstoring a dataset has an overhead to it. But if you want to hold certain information with relationships you might either need to hold your own serializable objects/dataset itself.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.