RE: HyperLinkField and FindControl
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Mon, 10 Apr 2006 07:49:28 GMT
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.)
.
- Prev by Date: RE: Display a record - several questions
- Next by Date: RE: FormView - initial template
- Previous by thread: RE: Display a record - several questions
- Next by thread: RE: FormView - initial template
- Index(es):
Relevant Pages
|