Thanks,
Rod
9 Answers, 1 is accepted
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
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
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!
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>
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?
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.
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>
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
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 >>