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

HyperlinkButton in GridView

12 Answers 356 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 25 Sep 2009, 04:51 PM
I want to put a HyperlinkButton in my GridView but I want to pass in a query string to the NavigateUri from my DataSource collection.  I know doesn't work but Is this even possible?

<

 

telerikGridView:GridViewColumn Width="*">

 

 

 

    <telerikGridView:GridViewColumn.CellStyle>

 

 

 

        <Style TargetType="GridView:GridViewCell">

 

 

 

            <Setter Property="Template">

 

 

 

                <Setter.Value>

 

 

 

                    <ControlTemplate TargetType="GridView:GridViewCell">

 

 

 

                        <Border BorderThickness="0,0,0,1" BorderBrush="#FFB3B3B3">

 

 

 

                            <HyperlinkButton x:Name="ViewDetailsButton" Content="View Details" NavigateUri="http://www.myurl.com/page.aspx?id={Binding Id}"/>

 

 

 

                        </Border>

 

 

 

                    </ControlTemplate>

 

 

 

                </Setter.Value>

 

 

 

            </Setter>

 

 

 

        </Style>

 

 

 

    </telerikGridView:GridViewColumn.CellStyle>

 

 

 

</telerikGridView:GridViewColumn>

Chris Buchanan
iomer Internet Solutions Inc.

 

12 Answers, 1 is accepted

Sort by
0
Ludovic Gerbault
Top achievements
Rank 1
answered on 25 Sep 2009, 05:48 PM
I think you could use some sort of converter, like

 <HyperlinkButton x:Name="ViewDetailsButton" Content="View Details" NavigateUri="{Binding Id, Converter={StaticResource UriConverter}}" />

And in your converter, you put something like

return "http://www.myurl.com/page.aspx?id="+value.toString();
0
Vlad
Telerik team
answered on 26 Sep 2009, 05:33 AM
Hi guys,

In our latest internal build we introduced two new columns: GridViewHyperlinkColumn and GridViewDynamicHyperlinkColumn. Here is an example for both columns:

...
<telerik:GridViewHyperlinkColumn DataMemberBinding="{Binding Url}" ContentBinding="{Binding CompanyName}" />
...

<telerik:GridViewDynamicHyperlinkColumn DataFormatString="Send mail to: {0}"
                                                 DataMemberBinding="{Binding CompanyName}"
                                                 NavigateUrlMemberPaths="ContactName, CompanyName"
                                                 NavigateUrlFormatString="mailto:{0}@{1}.com"/>

or

<telerik:GridViewDynamicHyperlinkColumn DataMemberBinding="{Binding MyProperty1}"
                                       TargetName="_blank"
                                       NavigateUrlMemberPaths="MyProperty2, MyProperty3"
                                       NavigateUrlFormatString="http://www.myurl.com/page.aspx?q1={0}&q2={1}"/>


All the best,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Chris
Top achievements
Rank 1
answered on 28 Sep 2009, 05:08 PM
Will this be in Q3, and if so do you have a release date for that?
0
Vlad
Telerik team
answered on 29 Sep 2009, 05:33 AM
Hello Chris,

You can download our latest internal build even now:
http://www.telerik.com/account/latest-internal-builds.aspx

Kind regards,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Axel Erize
Top achievements
Rank 1
answered on 07 Dec 2009, 11:05 PM
Hello,

Could you please explain how to programmatically add one GridViewHyperlinkColumn and one GridViewDynamicHyperlinkColumn to a RadGridView?

Thank you,

Axel
0
Vlad
Telerik team
answered on 08 Dec 2009, 07:33 AM
Hello,

There are no difference compared to other grid columns. All you need is to create the column, set desired properties and add the column in the Columns collection.

Sincerely yours,
Vlad
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Marc Roussel
Top achievements
Rank 2
answered on 05 Apr 2010, 01:16 PM
It seems that your properties do not exist anymore in Silverlight 4
they seems to have changed for DataMemberBinding, ContentBinding and DataFormatBinding
0
Marc Roussel
Top achievements
Rank 2
answered on 05 Apr 2010, 01:43 PM
Cannot navigate external relative to a page ?
when I click on the email

Here's my code

GridViewHyperlinkColumn gvhc = new GridViewHyperlinkColumn();  
gvhc.DataMemberBinding = new System.Windows.Data.Binding() { Path = new PropertyPath(BindingPath) };  
gvhc.ContentBinding = new System.Windows.Data.Binding() { Path = new PropertyPath(BindingPath) };  
gvhc.DataFormatString = "mailto:{0}";  
 

I also tried with "{}{mailto:{0}" with no luck
I tried "{}{0}" still no luck

For your information, the real value is a complete email like joe@company.com
0
Vlad
Telerik team
answered on 06 Apr 2010, 09:44 AM
Hi,

Please use GridViewDynamicHyperlinkColumn instead - I've attached an example project.

Best wishes,
Vlad
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
Marc Roussel
Top achievements
Rank 2
answered on 06 Apr 2010, 11:24 AM
It works well.  Thank you

So if I understand, GridViewDynamicHyperlinkColumn is used for hyperlinks and emails so what is the other for ?
Are these details found in the help somewhere ?
0
Vlad
Telerik team
answered on 08 Apr 2010, 08:48 AM
Hello Marc,

GridViewHyperlinkColumn will bind ContentProperty and NavigateUriProperty to the generated HyperlinkButton however GridViewDynamicHyperlinkColumn will construct Uri on the fly and will assign this Uri to NavigateUri of the generated HyperlinkButton directly.

Your actual data (joe@company.com) is not valid Uri - if this was mailto:joe@company.com GridViewHyperlinkColumn will work as well. In Silverlight 4 you can set StringFormat for your DataMemberBinding and this will affect the Uri.

Greetings,
Vlad
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
Marc Roussel
Top achievements
Rank 2
answered on 08 Apr 2010, 11:40 AM
Ah now I see.  Thank you
Tags
GridView
Asked by
Chris
Top achievements
Rank 1
Answers by
Ludovic Gerbault
Top achievements
Rank 1
Vlad
Telerik team
Chris
Top achievements
Rank 1
Axel Erize
Top achievements
Rank 1
Marc Roussel
Top achievements
Rank 2
Share this question
or