Editting GridHyperLinkColumn NavigateUrl in codebehind

4 posts, 1 answers
  1. Jim
    Jim avatar
    1 posts
    Member since:
    Sep 2011

    Posted 24 Nov 2011 Link to this post

    I would like to edit a gridhyperlinkcolumn's navigateurl in my code behind. I have tried:
    RadGrid grid = (RadGrid)sender;
    GridColumn column = grid.Columns.FindByUniqueName("ViewBus");
    (column as GridHyperLinkColumn).NavigateUrl = "www.google.ca";

    in both the PreRender and DataBound events. Any suggestions?
  2. Answer
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 24 Nov 2011 Link to this post


    You can try the following code snippet.
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        if (e.Item.ItemType == GridItemType.Item || e.Item.ItemType == GridItemType.AlternatingItem)
          GridDataItem dataItem = (GridDataItem)e.Item;
          //get the Hyperlink using the Column uniqueName
          HyperLink hyperLink = (HyperLink)dataItem["CompanyName"].Controls[0];
          hyperLink.NavigateUrl = "http://www.telerik.com/help/aspnet-ajax/introduction.html";

  3. Matt
    Matt avatar
    50 posts
    Member since:
    Jun 2012

    Posted 22 Jun 2016 Link to this post

    I did this exactly and it still doesn't work. Now, I know it's 2016, maybe something has changed but I wouldn't think that this would have....
  4. Eyup
    Eyup avatar
    3323 posts

    Posted 27 Jun 2016 Link to this post

    Hello Matt,

    Please make sure that the "ColumnName" you are using matches the UniqueName of the GridHyperLinkColumn - it is case-sensitive. Also, you can check the attached web site sample and try accessing the generated HyperLink there.

    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Back to Top