This is a migrated thread and some comments may be shown as answers.

disable link in gridhyperlinkcolumn

1 Answer 447 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Jeff
Top achievements
Rank 1
Jeff asked on 21 Jan 2010, 10:07 PM
We have a hierarchical grid with a gridhyperlinkcolumn at each level. There is a parameter that comes back with the NeedDataSource query called "active". If active is true we want the link to remain active. If it is false, we want the text label to remain but the link to be inactive.

Is there a way to do this?

thanks

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 22 Jan 2010, 05:33 AM
Hello,

Set the DataKeyNames as "active" and you can access corresponding value in ItemDataBound event. Then access the hyperlink in the row to disable according to your need.

cs:
 
    protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            if (item.GetDataKeyValue("active").ToString() == "true"
            { 
                HyperLink hLink = (HyperLink)item["HyperLinkColumn1"].Controls[0]; // Access the hyperlink in the row 
                hLink.Enabled = false;  // Disable hyperlink 
            } 
        } 
    } 

-Shinu.
Tags
Grid
Asked by
Jeff
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or