RE: HyperLinkField and FindControl

Tech-Archive recommends: Fix windows errors by optimizing your registry



Hi Dave,

Thank you for posting.

As for the Hyperlink field, since the hyperlink control within it is
autogenerated, so we can not reference it through ID, and one possible
approach is reference the control through control index, however, this is
dangerous and not recommended(you need to view the generated source(or use
some test code in RowDataBound event) to check the hyperlink control's
actual index).

For such scenario, I still think using TemplateField is the best choice.
And since VS IDE can help use convert a built-in column/field to a template
field, you can first define the hyperlink field (and make it work
correctly), then convert it to template field through IDE(in the
EditColumns wizard). Here is a sample TemplateField (in GridView) converted
from a HyperlinkField:

===========================
<asp:TemplateField>
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl='<%# Eval("CategoryID", "DataSourcePage.aspx?id={0}") %>'
Text='<%# Eval("CategoryName", "[{0}]")
%>'></asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
============================

Hope this helps.

Regards,

Steven Cheng
Microsoft Online Community Support


==================================================

When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.

==================================================


This posting is provided "AS IS" with no warranties, and confers no rights.



Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)





.



Relevant Pages

  • Data Access Pages problem
    ... text box displays a hyperlink. ... I noticed a 'Format' field in the 'Data' tab of the control, ... create the custom format for a Hyperlink field? ...
    (microsoft.public.access.formscoding)
  • Re: HyperLink Bug
    ... But what is the syntax to add it into the HyperLink object? ... The URL returned by this method is relative to the folder ... containing the source file in which the control is instantiated. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Command Button VB Coding
    ... of ReasonforEdit and DeleteDate in the control source of your reports' ... Make your report title an unbound text field and set its control ... Hyperlink1 - Hyperlink ...
    (microsoft.public.access.gettingstarted)
  • RE: Hyperlink Help
    ... Then right-click on the email address control and open the ... Daniel P ... The hyperlink will also work, but the prefix must be present. ...
    (microsoft.public.access.gettingstarted)
  • Re: HyperLink Bug
    ... I know that if a control loads another control the path ... As far as I can tell, I will have to go to any page that has a Hyperlink on ... relative to that particular user control and not the page. ... folder, you obviously want to go to the folder where the aspx files are. ...
    (microsoft.public.dotnet.framework.aspnet)