Gridview - HyperLinkField

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>
 
G

Guest

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"
 
G

Gregory A. Beamer

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,
 
P

Paul W Smith

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"
 
P

Paul W Smith

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

Thanks.
 
G

Gregory A. Beamer

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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top