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

[Solved] Conditional HyperLink

1 Answer 175 Views
Grid
This is a migrated thread and some comments may be shown as answers.
DavidA
Top achievements
Rank 1
DavidA asked on 23 Jul 2009, 03:26 PM
Hi,

I would like to have a conditional hyperlink, so that a hyperlink only shows if the value of CntNonMailable is not equal to 'N/A'. Is this possible?

I have a radgrid with the following Hyperlink column:

                <telerik:GridHyperLinkColumn DataTextFormatString="{0}"
                        DataNavigateUrlFields="ListID" UniqueName="CntNonMailable"
                         DataNavigateUrlFormatString="GetRejectedReport.aspx?ListID={0}"
                        HeaderText="Non Mailable" DataTextField="CntNonMailable">
                         <HeaderStyle Width="63px"></HeaderStyle>
                    </telerik:GridHyperLinkColumn>

Any help would be much appreciated.

thanks
David


1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 24 Jul 2009, 05:32 AM
Hi David,

You may achieve this in the code behind as shown below.

CS:
 
 protected void RadGrid1_ItemDataBound(object sender, GridItemEventArgs e) 
    { 
        if (e.Item is GridDataItem) 
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            HyperLink hyplnk = (HyperLink)item["CntNonMailable "].Controls[0]; 
            if (hyplnk.Text == "N/A"
                hyplnk.Visible = false
            else 
                hyplnk.Visible = true
        } 
    } 
 


Shinu
Tags
Grid
Asked by
DavidA
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or