Disable Hyperlink on Condition

3 posts, 1 answers
  1. L
    L avatar
    295 posts
    Member since:
    Apr 2008

    Posted 28 Nov 2009 Link to this post

    hi

    How do i disable hyperlink bases on Yes and No condition? Thanks

    <telerik:GridHyperLinkColumn HeaderText="Demo" Text="Demo"
                UniqueName="Demo" DataNavigateUrlFields="Demo_ID" 
                DataNavigateUrlFormatString="~/demo/demo.aspx?demo_id={0}">
    </telerik:GridHyperLinkColumn>
  2. Roland
    Roland avatar
    156 posts
    Member since:
    Feb 2009

    Posted 29 Nov 2009 Link to this post

    Hello

    One way would be converting column to templated column and disabling the hyperlink on item databound event.

  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Answer
    Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 29 Nov 2009 Link to this post

    Hello,

    You can try out the following code to disable HyperLinks for the HyperLinkColumn in the ItemDataBound event of the grid, based on some condition:
    c#:
    protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
        { 
            if (e.Item is GridDataItem) 
            { 
                GridDataItem dataItem = (GridDataItem)e.Item;             
                if (Condition == "Yes"
                { 
                    ((HyperLink)dataItem["Demo"].Controls[0]).Enabled = false
                } 
            } 
         } 

    Thanks
    Princy.
Back to Top