Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Hyperlink as button in gridview cell

 
 
Old 10-10-2007   #1 (permalink)
Scott Walters


 
 

Hyperlink as button in gridview cell

Hi,

I've managed to include a hyperlink with a click handler in a databound
gridview cell like this...

<GridViewColumn Header="Title">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock>
<Hyperlink Click="Hyper_OnClick">
<TextBlock Text="{Binding Path=AttachmentTitle}" />
</Hyperlink>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>


but can't figure out how to get the text for the link as a string inside
the hyperlink click handler. How can I do this?

My System SpecsSystem Spec
Old 11-03-2007   #2 (permalink)
mperren


 
 

Re: Hyperlink as button in gridview cell

On Oct 10, 4:32 pm, Scott Walters <scottw...@xxxxxx> wrote:
Quote:

> Hi,
>
> I've managed to include a hyperlink with a click handler in a databound
> gridview cell like this...
>
> <GridViewColumn Header="Title">
> <GridViewColumn.CellTemplate>
> <DataTemplate>
> <TextBlock>
> <Hyperlink Click="Hyper_OnClick">
> <TextBlock Text="{Binding Path=AttachmentTitle}" />
> </Hyperlink>
> </TextBlock>
> </DataTemplate>
> </GridViewColumn.CellTemplate>
> </GridViewColumn>
>
> but can't figure out how to get the text for the link as a string inside
> the hyperlink click handler. How can I do this?
I used your example -- works great by the way -- for a list of
customers that I had. When I clicked on the customer I wanted to edit
that record. Therefore, in the "Tag" of the Hyperlink I placed a
binding to the customer id. That was the easiest way I found to
recover information I needed about the record that was clicked. Here
is the snippet...

<ListView Name="customerList">
<ListView.View>
<GridView>
<GridViewColumn Header="Name">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock>
<Hyperlink Click="EditCustomer"
Tag="{Binding Path=customerid}">
<TextBlock Text="{Binding
Path=name}"/>
</Hyperlink>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>

and here is an example for accessing it...

MessageBox.Show("Customer: " +
((Hyperlink)sender).Tag.ToString());

.... it works great!

My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Gridview with more than 2 tables .NET General
Hyperlink from web page to specific cell in specific Excel sheet VB Script
CTP Out-GridView PowerShell
Hyperlink button malfunction Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46