Junior_Developer
asked on
multiple parameters in hyperlink
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:Bo undColumn>
<asp:TemplateColumn HeaderText = "Emp Name" >
<ItemTemplate>
<asp:HyperLink ID="Hyperlink1" Runat="server" NavigateUrl='<%# BuildUrlWithQueryString ("Details.aspx", "EmpID", Container.DataItem("EmpID" ), "EmpName", Container.DataItem("EmpNam e")) %>' />
</ItemTemplate>
</asp:TemplateColumn>
-- HERE IS THE BuildUrlWithQueryString which i have put in code behind file this is working fine
Function BuildUrlWithQueryString(By Val 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(arg s(i)) & "=" & _
HttpUtility.HtmlEncode(arg s(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("d etails.asp x", "EMPID", "111111111", "EmpName", "Dan")
---RESULT
details.aspx?EmpID=1111111 11&EmpName =Dan
--EmpId gets displayed on the web page but nothing gets displayed in the EmpName column
Thanks in advance
<Columns>
<asp:BoundColumn HeaderText="Emp ID" DataField="EmpID"></asp:Bo
<asp:TemplateColumn HeaderText = "Emp Name" >
<ItemTemplate>
<asp:HyperLink ID="Hyperlink1" Runat="server" NavigateUrl='<%# BuildUrlWithQueryString ("Details.aspx", "EmpID", Container.DataItem("EmpID"
</ItemTemplate>
</asp:TemplateColumn>
-- HERE IS THE BuildUrlWithQueryString which i have put in code behind file this is working fine
Function BuildUrlWithQueryString(By
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(arg
HttpUtility.HtmlEncode(arg
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("d
---RESULT
details.aspx?EmpID=1111111
--EmpId gets displayed on the web page but nothing gets displayed in the EmpName column
Thanks in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
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
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?
Thanks
is the hyperLink still within a datalist or datagrid , or just not within any control
ASKER