Solved

C# Gridview

Posted on 2008-10-27
7
427 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
[X]
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
  • 3
  • 3
7 Comments
 
LVL 12

Expert Comment

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

Expert Comment

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

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
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.

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 12

Accepted Solution

by:
techExtreme earned 500 total points
ID: 22829412
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
ID: 22838122
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
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.
0
 
LVL 1

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Can I command line build a C# application? 6 53
C# LINQ ForEach() question 6 85
jquery + C#.net radiobuttonlist 3 45
Need a simple RegEx to search for two words 27 84
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

749 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