473,791 Members | 2,995 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

using a query string to pass a hyperlinkfield value to another page

347 Contributor
I have a page with a gridview and I want to pass the value when a user clicks on a hyperlinked field in the grid to another page. Here is the code for the gridview:

Expand|Select|Wrap|Line Numbers
  1. <asp:GridView ID="GridView1" runat="server" HorizontalAlign="Center" 
  2.             AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
  3.             <Columns>
  4.                 <asp:BoundField DataField="SchedName" HeaderText="SchedName" 
  5.                     SortExpression="SchedName" />
  6.                 <asp:BoundField DataField="ActivityDate" HeaderText="ActivityDate" 
  7.                     ReadOnly="True" SortExpression="ActivityDate" />
  8.                 <asp:BoundField DataField="By" HeaderText="By" SortExpression="By" />
  9.                 <asp:BoundField DataField="Activity" HeaderText="Activity" ReadOnly="True" 
  10.                     SortExpression="Activity" />
  11.                 <asp:BoundField DataField="FirstListing" HeaderText="FirstListing" 
  12.                     SortExpression="FirstListing" />
  13.                 <asp:HyperLinkField DataTextField="OnCallStart" HeaderText="OncallStart" 
  14.                     NavigateUrl="\website1\Default2.aspx" SortExpression="OnCallStart" />
  15.                 <asp:BoundField DataField="OnCallEnd" HeaderText="OnCallEnd" ReadOnly="True" 
  16.                     SortExpression="OnCallEnd" />
  17.             </Columns>
  18.         </asp:GridView>
  19.  
and when a user clicks on the OncallStart field, I want to pass the values of whatever is in that field to the next page. Can someone give me an example of how to do that?

Thank you

Doug
Apr 21 '11 #1
2 2863
dougancil
347 Contributor
I receive the following error when I try to pass values between web pages:

Literal content ('<asp:HyperLin kField DataTextField=" OnCallStart" HeaderText="Onc allStart"
NavigateUrl="\w ebsite1\default 2.aspx" SortExpression= "OnCallStar t" DataNavigateUrl FormatString=”d efault.aspx?onc allstart={0}"/>') is not allowed within a 'System.Web.UI. WebControls.Dat aControlFieldCo llection'. Can someone please help me to pass values between 2 pages? I've read several forums and this seems to be the way to go but I can't make it work.

Thank you

Doug
Apr 21 '11 #2
Frinavale
9,735 Recognized Expert Moderator Expert
During the GridView's OnRowDataBound Event, set the URL of the HyperLink to include Query String parameters that you require in order to pass info to the second page.

-Frinny
Apr 27 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

3
7451
by: Dr. Oz | last post by:
Hi, I am trying to read in a query string from one page and build a link to another page based on the query string. Here's the code I am using to read in the query string: <script "text/javascript"> function getQueryVariable(variable) { var query = window.location.search.substring(1);
1
5789
by: Phil M | last post by:
I want a textfield on a form to show the result of a query (see below). Using the expression builder, I set Default Value to: =! But when I try the form, it comes up #Name? What am I doing wrong? Thanks!
2
2009
by: Martin Tully | last post by:
I am trying to a create a page that will query a SQLDB get customer information and then pass this information on to another page creating almost like a mail merge letter. I can get the information no problem using a repeater but how do I pass <%#container.DataItem("Value1")%> to another page. Thx.
2
962
by: Jeff Johnson [MVP: VB] | last post by:
Subject pretty much says it all. I'm testing a page that, at the moment, I have no links to from other pages. The page requires a query string, so simply setting it as the start page in the IDE is not enough. An analogy in VB would be to set the Command Line Parameters for a project. Yes, I could take 30 seconds out of my life and create a dummy HTML page that has the link I want, but for future reference I'd like to know whether what I...
18
44667
by: A.M | last post by:
Hi, Is there any way to call a WSS web service method by using browser and see the XML result in browser as well? I have been told that there is query string syntax for calling webservices.
2
6493
by: Milkstr | last post by:
is it possible to pass dynamic text through the query string command?? I know you can just pass a variale through a link eg. www.text1.com/text1.asp?username="Mike" but i want to use the dynamic text from a repaeting region something like www.text1.com/text1.asp?<%=(tempDB.fields.item("username").value%> this works kind of it shows the name in the next page, but how do i read this "?<%=(tempDB.fields.item("username").value%>" value on...
3
5617
by: Skip | last post by:
OK, I'm a novice in JS but have lots of coding experience. I am trying to accomplish something that would seem somewhat simple - BUT IT'S NOT. I have a basic window that calls another window with window.open and passes in 1 value using a querystring i.e., www.myhome.com/mypage?video=BAK-Extension Now when the window opens, I can capture the passed value in a JS function. But if I want to use that in the body of the HTML in a
1
1547
by: agarwasa2008 | last post by:
Hi, I am new to VB .NET programming. I need to display a value on a web form called FeatureList.aspx. Here are the details: The web form FeatureSearch.aspx contains a user control called FeatureSearch.ascx. The UserControl contains 20 rows following: So row 1 could be color with may be 3 radio button
3
14268
by: nse111 | last post by:
I use PHP sessions to pass a value from one page to another. In my 1st page I pass a value called 'id' to my 2nd page using a hyperlink. explained: <a href="abc.php?id=<?php print"$image_id";?>"></a>
0
9669
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9515
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10427
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10155
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9995
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6776
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5559
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4110
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3718
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.