Solved

multiple parameters in hyperlink

Posted on 2006-07-10
5
494 Views
Last Modified: 2009-07-29
I would like to pass multiple parameters with my hyperlink to other page here is want i have in .aspx file
<Columns>
    <asp:BoundColumn HeaderText="Emp ID" DataField="EmpID"></asp:BoundColumn>
    <asp:TemplateColumn HeaderText = "Emp Name" >
<ItemTemplate>
    <asp:HyperLink  ID="Hyperlink1" Runat="server" NavigateUrl='<%# BuildUrlWithQueryString  ("Details.aspx", "EmpID", Container.DataItem("EmpID"), "EmpName", Container.DataItem("EmpName")) %>' />
</ItemTemplate>
</asp:TemplateColumn>

-- HERE IS THE BuildUrlWithQueryString  which i have put in code behind file this is working fine

Function BuildUrlWithQueryString(ByVal baseUrl As String, _
    ByVal ParamArray args() As String)
        Dim params As String = ""
        Dim i As Integer
        For i = 0 To args.Length - 1 Step 2
            ' if this is not the first parameter, concatenate with &
            If params.Length > 0 Then params &= "&"
            ' add the param_name=param_value piece to the current params string
            params &= HttpUtility.HtmlEncode(args(i)) & "=" & _
                HttpUtility.HtmlEncode(args(i + 1))
        Next
        ' add the params to the base url and return the final string
        Return baseUrl & "?" & params
    End Function

--I HAVE TESTED THE FUNCTION LIKE THIS IT SEEMS TO ME THAT THE FUNCTION IS WORKING BUT I DONT KNOW WHY THE HYPERLINK VALUE DOESNOT GET DISPLAYED
Label2.Text = BuildUrlWithQueryString("details.aspx", "EMPID", "111111111", "EmpName", "Dan")
 ---RESULT
details.aspx?EmpID=111111111&EmpName=Dan

--EmpId gets displayed on the web page but nothing gets displayed in the EmpName column

Thanks in advance
0
Comment
Question by:Junior_Developer
  • 3
  • 2
5 Comments
 
LVL 11

Accepted Solution

by:
lijunguo earned 500 total points
ID: 17080662
are you using asp.net 1 or asp.net 2.0, if you're using .net 2.0 one way is:
NavigateUrl=' <%# "Details.aspx?EmpID="+Container.DataItem("EmpID")+"&EmpName=" + Container.DataItem("EmpName")) %>'

0
 

Author Comment

by:Junior_Developer
ID: 17081391
using 1.1
0
 
LVL 11

Expert Comment

by:lijunguo
ID: 17086035
well, let's look at your function,  are you sure you can compile your file with the function you posted?  Two things are missing, one is the function return type, the other is If not ended.
0
 

Author Comment

by:Junior_Developer
ID: 17086121
Its been a while no one responsed so i have changed it but now i basically need is this.
I have a hyperlink and need to pass 2 values from a page to be displayed on the details.aspx page

one value i want to send is selectedtext of dropdownlist and the other is in a textbox

<asp:hyperlink id="HyperLink1" style="Z-INDEX: 102; LEFT: 80px; POSITION: absolute; TOP: 224px"
runat="server" Width="120px" Target ="_blank" NavigateUrl="Details.aspx?">Add New Records

Thanks
0
 
LVL 11

Expert Comment

by:lijunguo
ID: 17087291
is the hyperLink still within a datalist or datagrid , or just not within any control
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

Title # Comments Views Activity
ASP.net VB.net Email  a webpage 3 31
ASP.NET Web Form Variables being reset 2 26
Two different visual studio versions 3 23
ASP.NET 5 Templates 2 66
In this Article, I will provide a few tips in problem and solution manner. Opening an ASPX page in Visual studio 2003 is very slow. To make it fast, please do follow below steps:   Open the Solution/Project. Right click the ASPX file to b…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

920 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

17 Experts available now in Live!

Get 1:1 Help Now