How can anchor tags (for internal links) be put into a gridview?
I have a long alphabetical list to be displayed by a gridview.
I n开发者_运维知识库eed to have links at the top of the page that will link to anchors in the gridview. How can I get anchor tags in the gridview so that the links will jump to them when clicked?
Note: Paging is not an option
Thanks!
Set the GridView's ClientIDMode to Static
or Predictable
(if using Framework 4.0) to avoid ASP.Net generating unique names according to their NamingContainers(GridViewRow). You should ensure that the ID's are unique by yourself from RowDataBound(f.e. append an identifier).
- MSDN
- http://www.shubho.net/2011/01/understanding-clientidmodepredictable.html
If you are using Framework < 4.0 you have to generate the HyperLink's NavigateUrl from RowDataBound of the GridView via the ClientID of your link targets.
<a name="anchor1">Text</a>
Link to anchor: <a href="#anchor1">Link</a>
精彩评论