gridview column values to another page via gridview hyperlink column

K

Keith G Hicks

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
 
G

gnewsgroup

Keith said:
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?
 
G

gnewsgroup

Keith said:
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?
 
K

Keith G Hicks

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!
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,440
Members
44,830
Latest member
ZADIva7383

Latest Threads

Top