I have datacolumn in my gridview that has either a url, or plain text. How do I toggle a Hyperlink in the HTML?
This is what I have so far… which returns “View Link…” with or without a url 🙁
<ItemTemplate>
<asp:HyperLink ID="HyperLink3" runat="server" Text="View Link..." NavigateUrl='<%# Bind("DocLink") %>' Target="_blank"></asp:HyperLink>
<asp:Label ID="Label8" runat="server" Text='<%# Bind("Details") %>'></asp:Label>
</ItemTemplate>
I’m not sure I understand your question, but if you are trying to selectively show or hide one of the controls in your ItemTemplate depending on the data, use the
OnItemDataBoundevent, useFindControl()to get the controls, and set theVisibleproperty on each appropriately.If your logic for Visible is relatively simple, you can add it right to your
ItemTemplate. Something like: