Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a gridview, in that I have a asp hyperlink control inside TemplateField but I am not able to find the control in SelectedIndexChanged event. I want to get the text of the hyperlink.

I am using CommandField for selecting the row.

CS Code -
C#
GridViewRow row = gridViewShipments.Rows[gridViewShipments.SelectedIndex];
HyperLink link = (HyperLink)row.FindControl("poNum"); // here link is always null.


ASPX Code -
XML
<asp:TemplateField>
        <ItemTemplate>
            <asp:HyperLink ID="poNum" Text='<% Eval("poNum") %>' NavigateUrl="#" runat="server"></asp:HyperLink>
        </ItemTemplate>
</asp:TemplateField>

Any idea why its always null ?
Posted

1 solution

Please rad this article to understand how templates are working in ASP.NET...
Understanding ASP.NET Templates[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900