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

Problem to open external link in GridView

6 Answers 100 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Pierre
Top achievements
Rank 1
Pierre asked on 27 Mar 2012, 08:26 AM
Hello,

I need some help. I have a gridview with three columns. 
In the first, the document name & In the second and the third, a hyperlink. 
I would like on the "click" of the line (so the SelectedChanged),open a document externally, the while keeping my selected row in my GridView. 

Initially, I used a Hyperlink to my document name. It worked but I didn't keep the selected row.
And when I had a hundred lines, I didn't know that I had just opened (where the interest of keeping my line selected on opening an external link).

Do you have an idea for my problem to open external link on the SelectedChanged ?

Thank you ;)

6 Answers, 1 is accepted

Sort by
0
Pierre
Top achievements
Rank 1
answered on 29 Mar 2012, 02:22 PM
A little "Up"
Some one have an idea? 
0
Dimitrina
Telerik team
answered on 30 Mar 2012, 03:03 PM
Hello,

 You could define a CellTemplate for your column. In the CellTemplate use a HyperlinkButton and subscribe for its Click event. Once the event is raised you can handle the Selection programmatic.
For example:

private void HyperlinkButton_Click(object sender, RoutedEventArgs e)
        {
            GridViewRow parentRow = ((HyperlinkButton)sender).ParentOfType<GridViewRow>();
            parentRow.IsSelected = true;
        }

Greetings,
Didie
the Telerik team
Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
0
Pierre
Top achievements
Rank 1
answered on 02 Apr 2012, 08:48 AM
Hello,

Thanks for your idea but it doesn't work..
In fact, I have an error : " ParentOfType isn't a member of System.Windows.Controls.HyperlinkButton "

This is my code :

Dim parentRow As GridViewRow = DirectCast(sender, HyperlinkButton).ParentOfType(Of GridViewRow)()
parentRow.IsSelected = True

I tried to remplaced "GridViewRow" by "GridViewCell".. but with no succes..

Dim parentRow As GridViewCell = DirectCast(sender, HyperlinkButton).Parent
parentRow.IsSelected = True

An other idea, please :) ?
0
Pierre
Top achievements
Rank 1
answered on 05 Apr 2012, 09:55 AM
A New Up ;)
An idéa ? 
0
Pierre
Top achievements
Rank 1
answered on 19 Apr 2012, 08:40 AM
A New Up ;)
An idéa ?  
Please 
0
Vlad
Telerik team
answered on 19 Apr 2012, 08:43 AM
Hello,

 You need to add Telerik.Windows.Controls namespace in your usings to use these extension methods. 

Regards,
Vlad
the Telerik team

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

Tags
GridView
Asked by
Pierre
Top achievements
Rank 1
Answers by
Pierre
Top achievements
Rank 1
Dimitrina
Telerik team
Vlad
Telerik team
Share this question
or