Solved

C# Gridview

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

Expert Comment

by:techExtreme
Comment Utility
hello,
Can you plz elaborate on what exactly you want to pass across pages from the gridview?
0
 
LVL 1

Expert Comment

by:Abh4IT
Comment Utility
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

ASP.NET
http://aspnet.4guysfromrolla.com/articles/091003-1.aspx
.NET Paging
www.geocities.com/jeff_louie/net_paging.htm
0
 

Author Comment

by:MRManthani
Comment Utility
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.

0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 12

Accepted Solution

by:
techExtreme earned 500 total points
Comment Utility
Hello,
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


Session["priceVarA"]=label1.text;
Session["priceVarB"]=label2.text;
Response.Redirect("page2.aspx");


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

Page_Load(...)

...

if not ispostback then


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

...

end if

Hope it helped.
0
 
LVL 1

Expert Comment

by:Abh4IT
Comment Utility
Hi,

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.

HTH
0
 
LVL 12

Expert Comment

by:techExtreme
Comment Utility
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.
0
 
LVL 1

Expert Comment

by:Abh4IT
Comment Utility
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.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

744 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now