Windows Vista Forums

Hyperlink as button in gridview cell
  1. #1


    Scott Walters Guest

    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

  2. #2


    mperren Guest

    Re: Hyperlink as button in gridview cell

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

    > 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

Hyperlink as button in gridview cell problems?

Similar Threads
Thread Thread Starter Forum Replies Last Post
Only 10 columns in out-gridview gurbao PowerShell 0 03 Feb 2009
Hyperlink from web page to specific cell in specific Excel sheet Quetzalcoatl VB Script 0 03 Sep 2008
CTP Out-GridView Doug PowerShell 3 26 Nov 2007
Hyperlink button malfunction msnews.microsoft.com Vista mail 5 04 Apr 2007
GridView Joachim Wester Avalon 1 04 Feb 2006