Gridview - HyperLinkField

  • Thread starter Thread starter Paul W Smith
  • Start date Start date
P

Paul W Smith

I would like to amend the code below to produce a url of:

{TeamName}.aspx rather than Teampage.aspx?TeamName={TeamName}

What chnages do I need to make to achieve this?


<asp:HyperLinkField
datatextfield="TeamName"
datanavigateurlfields="TeamName"
datanavigateurlformatstring="Teampage.aspx?TeamName={0}" >

<ItemStyle Font-Bold="True" Font-Size="16pt" ForeColor="#000066"
HorizontalAlign="Left" />

</asp:HyperLinkField>
 
I would like to amend the code below to produce a url of:

{TeamName}.aspx rather than Teampage.aspx?TeamName={TeamName}

What chnages do I need to make to achieve this?

<asp:HyperLinkField
    datatextfield="TeamName"
    datanavigateurlfields="TeamName"
    datanavigateurlformatstring="Teampage.aspx?TeamName={0}" >

<ItemStyle Font-Bold="True" Font-Size="16pt" ForeColor="#000066"
HorizontalAlign="Left" />

</asp:HyperLinkField>

You need to change datanavigateurlformatstring value to be as

"{0}.aspx"
 
I would like to amend the code below to produce a url of:

{TeamName}.aspx rather than Teampage.aspx?TeamName={TeamName}

What chnages do I need to make to achieve this?


<asp:HyperLinkField
datatextfield="TeamName"
datanavigateurlfields="TeamName"
datanavigateurlformatstring="Teampage.aspx?TeamName={0}" >

<ItemStyle Font-Bold="True" Font-Size="16pt" ForeColor="#000066"
HorizontalAlign="Left" />

</asp:HyperLinkField>


In theory, this will work:

<asp:HyperLinkField
datatextfield="TeamName"
datanavigateurlfields="TeamName"
datanavigateurlformatstring="{0}.aspx" >

The reason it should work in theory is the substitution is like this:

String.Format("{0}", teamName);

It might not work, however, due to constraints in the class.

If it does not work, you can hand craft the hyperlink using the row data
bound event handler and craft the string however you would like. This is
done in code, not tags, however. And, I know this will work.

Peace and Grace,


--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Thanks your solution works.

I tried so many options, I was sure I had tried that obvious one... but
obviously not!

Thanks again.


I would like to amend the code below to produce a url of:

{TeamName}.aspx rather than Teampage.aspx?TeamName={TeamName}

What chnages do I need to make to achieve this?

<asp:HyperLinkField
datatextfield="TeamName"
datanavigateurlfields="TeamName"
datanavigateurlformatstring="Teampage.aspx?TeamName={0}" >

<ItemStyle Font-Bold="True" Font-Size="16pt" ForeColor="#000066"
HorizontalAlign="Left" />

</asp:HyperLinkField>

You need to change datanavigateurlformatstring value to be as

"{0}.aspx"
 
Your first solution worked - sorry I did not understand your second option,
but thankfully for me I did not need it.

Thanks.
 
Your first solution worked - sorry I did not understand your second
option, but thankfully for me I did not need it.

The second option requires programming. Glad the first worked. ;-)

Peace and Grace,

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

Twitter: @gbworld
Blog: http://gregorybeamer.spaces.live.com

*******************************************
| Think outside the box! |
*******************************************
 
Back
Top