Solved

How can I pass a variable through the query string from one listview to another?

Posted on 2009-04-09
4
258 Views
Last Modified: 2013-12-17
I have written a C# .Net web site using visual studio 2008. I have two pages, each containing a asp.net 3.5 listview control bound to a linqdatasorce. All I want to do is pass a variable from one listview to the other through the query string, is this possible?
0
Comment
Question by:Shepwedd
  • 3
4 Comments
 
LVL 15

Expert Comment

by:spprivate
ID: 24107496
There are two way to do this.
When ever you want to go to next page form the querysring something like this.
Response.redirect ("../page2.aspx?param1="+listviewcontrol.selectedvalue;
In the other page
listview2.selectedvalue=Request.Querystring["param"].toString();

Or
Put the value in a Session. So Session["myval"]=istviewcontrol.selectedvalue;
in page 2
listview2.selectedvalue=Session["myval"].tostring();

Make sure in either cases check for null conditions
0
 

Author Comment

by:Shepwedd
ID: 24108102
Using your first approach, on the second listview upon using my version of:

listview2.selectedvalue=Request.Querystring["param"].toString();

I get the error: cannot be assigned to, it is read only?

0
 

Author Comment

by:Shepwedd
ID: 24108117
...and I was entering the code within my LinqDataSources OnSelecting event.
0
 

Accepted Solution

by:
Shepwedd earned 0 total points
ID: 24136759
This solution is as simple as:

<asp:HyperLink runat="server" id="hlNavigate" NavigateUrl='<%#  "~/trustAccounts.aspx?Id=" + Eval("TrustID") %>' Text="Accounts" />
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

This document covers how to connect to SQL Server and browse its contents.  It is meant for those new to Visual Studio and/or working with Microsoft SQL Server.  It is not a guide to building SQL Server database connections in your code.  This is mo…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …

911 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

21 Experts available now in Live!

Get 1:1 Help Now