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

Hyperlink column containing regular text (not hyperlinks)?

4 Answers 25 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vassili King
Top achievements
Rank 1
Vassili King asked on 14 Mar 2011, 06:59 PM

Hello,

I have a GridViewDynamicHyperlinkColumn as one of the columns of my GridView that lists users of one of my systems. The hyperlink is formed for each record in my data set by appending a user id to a hardcoded url. The resulting URLs lead to users' pages (a user name is displayed in the column, but when user clicks one the name, a new page opens with his/her page in it).

Some users, however, do not have these pages set up for them. I have a flag in my data set that lets me see which user has a parge, and which one does not. Is there a way to display just their name in plain text (not in the hyperlink form, that is) if their corresponding data set flag dictates so (i.e., if the user does not have a page set up) in the GridViewDynamicHyperlinkColumn?

Thank you!
-VK.

4 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 15 Mar 2011, 11:47 AM
Hi Vassili,

 
I believe that in your case the better option is to define a GridViewDataColumn with a HyperlinkButton in its CellTemplate. Based on the defined flag, you may return the appropriate CellTemplate with a TextBlock using DataTemplateSelectors. You may check this demo.


Greetings,
Vanya Pavlova
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Vassili King
Top achievements
Rank 1
answered on 15 Mar 2011, 04:43 PM
Hello Vanya,

I'm building my columns programmatically. It is not clear to me how to convert the XAML example you are referring to into C# code. Could you please direct me in a right way?

Here is, briefly, how my columns are built:

GridViewDataColumn gc;
GridViewDynamicHyperlinkColumn ghlc;
DataTemplate dt;
 
//Shared columns
//vCard (I'm building this coulm from a ImageButtonColumn_Email : GridViewColumn class that uses public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)) 
this.rgvMainGrid.Columns.Add(new ImageButtonColumn_Vcard() {     Header = "" }); //email (I'm building this coulm from a ImageButtonColumn_Email : GridViewColumn class that uses public override FrameworkElement CreateCellElement(GridViewCell cell, object dataItem)) this.rgvMainGrid.Columns.Add(new ImageButtonColumn_Email() {     Header = "" }); //Name ghlc = new GridViewDynamicHyperlinkColumn(); ghlc.Header = "Name"; ghlc.DataMemberBinding = new Binding("Name"); ghlc.NavigateUrlFormatString = "http://myIntranetAddress.net/{0}"; ghlc.NavigateUrlMemberPaths = "LanID"; ghlc.TargetName = "_blank"; ghlc.CellStyle = (Style)Application.Current.Resources["ArrowStyle"];







After this I build a few more columns, but those are irrelevant for this example.



Thank you very much for your help!
-VK.

0
Accepted
Vanya Pavlova
Telerik team
answered on 16 Mar 2011, 08:23 AM
Hello Vassili,

 
Thank you for sharing this snippet with us. I have prepared an example for you that demonstrates how to implement the proposed solution above with dynamic columns.

Please check the attached project and let me know in case you need any further assistance.
 

Greetings,
Vanya Pavlova
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
Vassili King
Top achievements
Rank 1
answered on 16 Mar 2011, 05:23 PM
Thank you, Vanya. You are the best!
Tags
GridView
Asked by
Vassili King
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Vassili King
Top achievements
Rank 1
Share this question
or