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

How to use GridViewHyperlinkColumn

9 Answers 190 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Rod Yager
Top achievements
Rank 1
Rod Yager asked on 09 Jun 2011, 04:35 PM
I would like to have my first column of my gridview be a hyperlink that I can execute my own code and navigate to a specific part of our application. Can someone tell me how I can acheive this? I am not navigating to a web url, but simply running c# code within the application.

Thanks,
Rod

9 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 14 Jun 2011, 12:23 PM
Hi Rod Yager,

From your explanation it seems you actually do not need a hyperlink , but a regular button .

So the recommended approach here would be : place a button in a DataTemplate.
Then set this DataTemplate to the CellTemplate property of the column.

*Additionally if you need the button to look like a hyperlink , it can be easily styled.

In case you have troubles implementing this , just let me know and I will paste some sample code here.

Regards,
Pavel Pavlov
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Steven
Top achievements
Rank 1
answered on 12 Aug 2011, 05:29 PM
Hi,

I am interesseted in the code that style a button likea Hyperlink in the GridViewHyperlinkColumn.
I would like to use it like a button.

Regards.
S

PS : Could you please post your code directly on this page, I am not allowed to download .zip Thanks
0
Vanya Pavlova
Telerik team
answered on 14 Aug 2011, 02:48 PM
Hello Steven,

 

The snippet below demonstrates how this can be achieved using a Style and the corresponding DataTemplate:


<Style x:Key="hyperlinkStyle" TargetType="telerik:RadButton">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="telerik:RadButton">
<TextBlock TextDecorations="Underline">
<ContentPresenter Content="{TemplateBinding  Content}" ContentTemplate="{TemplateBinding  ContentTemplate}" ..../>
</TextBlock>
</ControlTemplate>
</Setter>
</Setter>
</Style>
...
<telerik:GridViewDataColumn DataMemberBinding="{Binding UrlString}">
<telerik:GridViewDataColumn.CellTemplate>
<DataTemplate>
 <telerik:RadButton Content="{Binding UrlString}" Style="{StaticResource hyperlinkStyle}"...../>
</DataTemplate>
</telerik:GridViewDataColumn.CellTemplate>
</>


Hope this helps!

Best wishes,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Steven
Top achievements
Rank 1
answered on 16 Aug 2011, 05:01 PM
Thanks !
0
Gelai
Top achievements
Rank 1
answered on 28 Aug 2012, 08:22 AM
Hello. Can you please post a sample solution? I tried the code above using a command binding but didn't work. :( 
0
Saibal
Top achievements
Rank 1
answered on 03 Jun 2013, 09:31 AM
Hi,

I am using the code as you specified above. But the an ObservableCollection<Object> is mapped to RadGridView's Item source. Now, on clicking the Button, the "Button_Click" event is getting fired. But, It's neither returning the Row number nor the content of the row. hence "gridViewDetails.SelectedItem" is always returning Null. Clicking that button does not select the row also.

Can you give me a code snippet as part of the solution of the above problem?
0
Vanya Pavlova
Telerik team
answered on 03 Jun 2013, 01:49 PM
Hi Saibal,


Have you checked this one? The WPF approach is pretty much the same.
Hope this helps!



Regards,
Vanya Pavlova
Telerik

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

0
Praveen
Top achievements
Rank 1
answered on 04 Sep 2013, 05:27 AM
Vanya,

I have tried your code show a column data as hyperlink. But seems column is populating with blank data. Here is the code I followed.

 <Style x:Key="hyperlinkStyle" TargetType="telerik:RadButton">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="telerik:RadButton">
                        <TextBlock TextDecorations="Underline">
                            <ContentPresenter Content="{TemplateBinding  Content}" ContentTemplate="{TemplateBinding  ContentTemplate}" />
                        </TextBlock>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
  </Style>

 <telerik:GridViewDataColumn Header="Test Name" DataMemberBinding="{Binding TestName}">
                <telerik:GridViewDataColumn.CellTemplate>
                              <DataTemplate>
                                                <telerik:RadButton Content="{Binding TestName}" Style="{StaticResource hyperlinkStyle}"/>
                               </DataTemplate>
                 </telerik:GridViewDataColumn.CellTemplate>
 </telerik:GridViewDataColumn>
0
Vanya Pavlova
Telerik team
answered on 09 Sep 2013, 08:22 AM
Hi Praveen,



We have tried to replicate the behavior you described, however to no avail. 
Would it be possible to isolate the problem in a small runnable project and sent it back to us as an attachment in a new support thread?  



Regards,
Vanya Pavlova
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Rod Yager
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Steven
Top achievements
Rank 1
Vanya Pavlova
Telerik team
Gelai
Top achievements
Rank 1
Saibal
Top achievements
Rank 1
Praveen
Top achievements
Rank 1
Share this question
or