By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,836 Members | 2,055 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,836 IT Pros & Developers. It's quick & easy.

Hyperlink Column & Helper Function not working

P: n/a
Hello All.

I keep asking for help with this on the www.asp.net forums and nobody seems
to be able to help. What I'm trying to accomplish is very simple. I simply
want to create a Hyperlink Column in a Datagrid and reformat the text output
of the column. The helper function seems to be working but the hyperlink
column isn't properly being render into html. The actual hyperlink web
control is showing up in the html when tested on two unique servers.

I'd be grateful if someone here could help! Thanks!
-Shane Fowlkes

Test Page: http://www.vrmca.com/membership/producers.aspx

My Code:
************************************************** *
Function EncryptSpaces(Company As String) As String
Company = Replace(Company," ","%20")
Return Company
End Function

....etc.....

<form runat="server">
<asp:datagrid id="dgProducers" runat="server"
HorizontalAlign="Center"
...etc.....
Width="90%">

<columns>
<asp:TemplateColumn HeaderText="Company">
<ItemTemplate>
<asp:HyperLink NavigateUrl ='<%# "memdetails.aspx?org=" &
EncryptSpaces(Container.DataItem("Company")) %>'>
<%# Container.DataItem("Company") %>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="# of Members" DataField="CountOfMember" />
</columns>
</asp:datagrid>
</form>

**********************************

And the HTML comes out like.....
<td>
<asp:HyperLink NavigateUrl
='memdetails.aspx?org=Hard%20Rock%20Concrete%20LLC '> Hard Rock Concrete
LLC</asp:HyperLink>
</td>


Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I've seen this many times before and what I do is create a function to return
my complete URL.

Function EncryptSpaces(Company As String) As String
Return Server.UrlEncode("memdetails.aspx?org=" & Company)
End Function

<ItemTemplate>
<asp:HyperLink NavigateUrl ='<%#
EncryptSpaces(Container.DataItem("Company")) %>'>
<%# Container.DataItem("Company") %>
</asp:HyperLink>
</ItemTemplate>

HTH
"D. Shane Fowlkes" wrote:
Hello All.

I keep asking for help with this on the www.asp.net forums and nobody seems
to be able to help. What I'm trying to accomplish is very simple. I simply
want to create a Hyperlink Column in a Datagrid and reformat the text output
of the column. The helper function seems to be working but the hyperlink
column isn't properly being render into html. The actual hyperlink web
control is showing up in the html when tested on two unique servers.

I'd be grateful if someone here could help! Thanks!
-Shane Fowlkes

Test Page: http://www.vrmca.com/membership/producers.aspx

My Code:
************************************************** *
Function EncryptSpaces(Company As String) As String
Company = Replace(Company," ","%20")
Return Company
End Function

....etc.....

<form runat="server">
<asp:datagrid id="dgProducers" runat="server"
HorizontalAlign="Center"
...etc.....
Width="90%">

<columns>
<asp:TemplateColumn HeaderText="Company">
<ItemTemplate>
<asp:HyperLink NavigateUrl ='<%# "memdetails.aspx?org=" &
EncryptSpaces(Container.DataItem("Company")) %>'>
<%# Container.DataItem("Company") %>
</asp:HyperLink>
</ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn HeaderText="# of Members" DataField="CountOfMember" />
</columns>
</asp:datagrid>
</form>

**********************************

And the HTML comes out like.....
<td>
<asp:HyperLink NavigateUrl
='memdetails.aspx?org=Hard%20Rock%20Concrete%20LLC '> Hard Rock Concrete
LLC</asp:HyperLink>
</td>


Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.