static Control FindAnchorControl(GridViewRow row) { Control anchorControl = row.GetAllChildren().OfType <WebControl>().FirstOrDefault(c => c.Attributes["IsTreeNodeAnchor"] != null && c.Attributes["IsTreeNodeAnchor"].ToLower() == "true"); if (anchorControl == null) { anchorControl = row.GetAllChildren().OfType <HtmlControl>().FirstOrDefault(c => c.Attributes["IsTreeNodeAnchor"] != null && c.Attributes["IsTreeNodeAnchor"].ToLower() == "true"); } return(anchorControl); }