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

Conditinal hyperlink

2 Answers 105 Views
Grid
This is a migrated thread and some comments may be shown as answers.
wdudek
Top achievements
Rank 1
wdudek asked on 16 Apr 2008, 08:53 PM
I have a column in the rad grid that has a tracking number, in some cases it is a ups tracking number that can be used in a hyperlink to go to their site and view information. In other cases it is for a differnt shipper and can't be used for any hyperlink. Assuming that I can determine when it is valid for a hyperlink is there a way to conditionally put a hyperlink into a column of the grid?

For example if the grid had 1 column "shipper"

Rows 1 and 2 would have a hyperlink in this column while row 3 would just have text.

Thanks

Bill

2 Answers, 1 is accepted

Sort by
0
Accepted
Vlad
Telerik team
answered on 17 Apr 2008, 06:54 AM
Hello Bill,

You can use ItemCreated with GridTemplateColumn to add desired control in desired cell. Here is an example:

<telerik:GridTemplateColumn UniqueName="MyColumn">
  <ItemTemplate></ItemTemplate>
</telerik:GridTemplateColumn>

...
if(e.Item is GridDataItem)
{
    if(your condition)
    {
       ((GridDataItem)e.Item)["MyColumn"].Controls.Add(MyControl1);
    }
    else
    {
        ((GridDataItem)e.Item)["MyColumn"].Controls.Add(MyControl2);
    }
}
...

Greetings,
Vlad
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
wdudek
Top achievements
Rank 1
answered on 21 Apr 2008, 06:51 PM
Thanks that worked great
Tags
Grid
Asked by
wdudek
Top achievements
Rank 1
Answers by
Vlad
Telerik team
wdudek
Top achievements
Rank 1
Share this question
or