gridview column values to another page via gridview hyperlink column

Discussion in 'ASP .Net' started by Keith G Hicks, Feb 18, 2008.

  1. I have a GridView on a page called "MissingPersons.aspx". One of the columns
    is an unbound hyperlink column. I do not want to show the "select" column in
    the grid. So "Enable Selection" is not checked. The grid is a list of
    missing people. Visitors can look at the list and click the hyperlink column
    to navigate to another page where they can fill in info on that person.

    The GridView has 3 other columns (in addition to the hyperlink column
    mentioned above). They are MissingPersonID (primary key of the table the
    grid is based on); FirstName; LastName.

    I need code in the page with the GridView that finds the value of the 3
    columns and then passes those values to the 2nd page which will show all 3
    values in TextBoxes.

    I have no idea where to even begin on some of this. I'm using VB (not using
    code-behind). I need some soft of event that fires when the user clicks the
    hyperlink column and then set the 3 values somewhere and then navigate to
    the 2nd page where it can see those values.

    Thanks,

    Keith
     
    Keith G Hicks, Feb 18, 2008
    #1
    1. Advertising

  2. Keith G Hicks

    gnewsgroup Guest

    Re: gridview column values to another page via gridview hyperlinkcolumn

    Keith G Hicks wrote:
    > I have a GridView on a page called "MissingPersons.aspx". One of the columns
    > is an unbound hyperlink column. I do not want to show the "select" column in
    > the grid. So "Enable Selection" is not checked. The grid is a list of
    > missing people. Visitors can look at the list and click the hyperlink column
    > to navigate to another page where they can fill in info on that person.
    >
    > The GridView has 3 other columns (in addition to the hyperlink column
    > mentioned above). They are MissingPersonID (primary key of the table the
    > grid is based on); FirstName; LastName.
    >
    > I need code in the page with the GridView that finds the value of the 3
    > columns and then passes those values to the 2nd page which will show all 3
    > values in TextBoxes.
    >
    > I have no idea where to even begin on some of this. I'm using VB (not using
    > code-behind). I need some soft of event that fires when the user clicks the
    > hyperlink column and then set the 3 values somewhere and then navigate to
    > the 2nd page where it can see those values.
    >
    > Thanks,
    >
    > Keith


    I have done this in a project of mine. you can format the hyperlink
    by binding the columns values to query string variables. got the idea?
     
    gnewsgroup, Feb 18, 2008
    #2
    1. Advertising

  3. Keith G Hicks

    gnewsgroup Guest

    Re: gridview column values to another page via gridview hyperlinkcolumn

    Keith G Hicks wrote:
    > I have a GridView on a page called "MissingPersons.aspx". One of the columns
    > is an unbound hyperlink column. I do not want to show the "select" column in
    > the grid. So "Enable Selection" is not checked. The grid is a list of
    > missing people. Visitors can look at the list and click the hyperlink column
    > to navigate to another page where they can fill in info on that person.
    >
    > The GridView has 3 other columns (in addition to the hyperlink column
    > mentioned above). They are MissingPersonID (primary key of the table the
    > grid is based on); FirstName; LastName.
    >
    > I need code in the page with the GridView that finds the value of the 3
    > columns and then passes those values to the 2nd page which will show all 3
    > values in TextBoxes.
    >
    > I have no idea where to even begin on some of this. I'm using VB (not using
    > code-behind). I need some soft of event that fires when the user clicks the
    > hyperlink column and then set the 3 values somewhere and then navigate to
    > the 2nd page where it can see those values.
    >
    > Thanks,
    >
    > Keith


    I have done this in a project of mine. you can format the hyperlink
    by binding the columns values to query string variables. got the idea?
     
    gnewsgroup, Feb 18, 2008
    #3
  4. No. I had no idea where to start. It took me all night to figure this out
    and pretty much none of the help I found online was complete enough to help
    someone new like me. Sorry to say if you're going to post help to someone
    that's clearly confused and has no idea where to begin and you're goign to
    be as vague as you were below, don't even bother. It's like a kick in the
    face and only makes learning more frustrating.

    People kept talking about turnign the column into a template column but
    that's not necessary at all. You just have to include both values in the
    DataNavigateUrlFields and in the DataNavigateUrlFormatString properties.
    What nobody mentions is that the index # used in the
    DataNavigateUrlFormatString property does NOT refer to the grid column but
    to the field in DataNavigateUrlFields. So you end up with something like
    this in the code:

    <asp:HyperLinkField
    DataNavigateUrlFields="MissingClassmateID,MissingClassmateFullName"
    DataNavigateUrlFormatString="MissingClassmateInfo.aspx?MissingClassmateID={0
    }&amp;MissingClassmateFullName={1}" Text="I know where this person is!" />

    There's no need for the text in the column to be bound to anything in the
    datasource although it could be. I didn't want it to be so I'm using "I know
    where this person is" as the hyperlink text. The other columns show the
    person's name and such. As you can see the DataNavigateUrlFields property
    has 2 fields listed separated by commas (MissingCLassmateID &
    MissingClassmateFullName). The DataNavigateUrlFormatString property shows
    the page to go to, then the ? for the parameters and then each of the 2
    parameters after that. The {0} and the {1} refer to the fields listed in
    DataNavigateUrlFields.

    Now I have simple code in the target page using
    Request.QueryString("MissingClassmateID").ToString, etc. to assign those
    values to text boxes on the target page.

    Anyway, this works perfectly. It wasn't really tricky to do. In fact once I
    realized that I needed the same # of parameters in each of the 2 properties
    above and that the index # refers to the first property (and not the grid
    columns) it was easy. The problem is that I didnt find that explained
    clearly anywhere at all. Everyone tried to make it WAY too complicated. Ugh!



    "gnewsgroup" <> wrote in message
    news:...
    >
    > I have done this in a project of mine. you can format the hyperlink
    > by binding the columns values to query string variables. got the idea?
     
    Keith G Hicks, Feb 18, 2008
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?WVNSYW8=?=
    Replies:
    1
    Views:
    480
    avnrao
    May 31, 2004
  2. davetichenor
    Replies:
    1
    Views:
    844
    Eliyahu Goldin
    Oct 30, 2006
  3. Greg Smith
    Replies:
    0
    Views:
    542
    Greg Smith
    Apr 12, 2007
  4. Dave
    Replies:
    0
    Views:
    957
  5. Greg Smith
    Replies:
    0
    Views:
    162
    Greg Smith
    Apr 12, 2007
Loading...

Share This Page