Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

C# Gridview

Posted on 2008-10-27
Last Modified: 2012-05-05
I want to pass Gridview values across pages. Could you please provide me the syntax for this?
Question by:MRManthani
  • 3
  • 3
LVL 12

Expert Comment

ID: 22815779
Can you plz elaborate on what exactly you want to pass across pages from the gridview?

Expert Comment

ID: 22819407
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

Author Comment

ID: 22829306
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.

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 12

Accepted Solution

techExtreme earned 500 total points
ID: 22829412
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.

Expert Comment

ID: 22838122

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.

LVL 12

Expert Comment

ID: 22841627
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.

Expert Comment

ID: 22847458
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.

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Finally almost got it 5 48
Hey Audio! 9 44
HTML - Color not displaying correctly in EMAIL. 6 49
insert value of checklistbox checked 4 32
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question