Hi Jack,
Use following code
If e.Item.ItemType = ListItemType.AlternatingItem OrElse _
e.Item.ItemType = ListItemType.Item Then
Dim ExpireAncor As HyperLink = CType(e.Item.FindControl
("DeleteHyperlink"), HyperLink)
' ...
End If
HTH
Elton Wang
>-----Original Message-----
>Hi,
>
>I have a datagrid and I'm wanting to access one of the
hyperlinks
>which is located in Template Column i.e.
>
><asp:TemplateColumn HeaderText="Action">
> <HeaderStyle Width="100px"></HeaderStyle>
> <ItemTemplate>
>
> <asp:hyperlink ID="DeleteHyperlink" runat="server"
>NavigateUrl="main.aspx">Delete</asp:hyperlink>
>
> </ItemTemplate>
></asp:TemplateColumn>
>
>I need to do this because I want to add some javascript
to the
>Attributes property ( i.e. DeleteHyperlink.Attributes.Add
("OnClick",
>"return confirm('Doyou really want todelete?'")
>
>How do I find this control in the ItemDataBound event???
>
>I tried this but it didn't work:
>Dim ExpireAncor As HyperLink =
>CType(e.Item.FindControl("ExpireAncor"), HyperLink)
>
>Any suggestions would be great.
>
>Cheers,
>Jack
>.
>