views:

148

answers:

2

Hi. I have a problem regarding listview control in asp.net and vb.net. I'm developing a web based application wherein the user will search for a topic and the search results will be displayed and bind in a listview. There's a link in a listview where users can click to view a file.

I want to get the selected value of each item in a listview after the user clicked the link.

Anyone knows how to do it?

Thanks.

+1  A: 

EDITED following comment below:

Here I think your only option, as this is ASP.NET (and not MVC I'm guessing), is to pass the data to your subsequent page as parameter data. Given that you are retrieving a list from somewhere may be there is an ID for the record that you could append to your link URL for each item, i.e. "...?id=xxxxx"

Then process this parameter in your 'file viewer' page. Going that route you could retrieve any element from the backing store that you presented previously.

There's no point in trying to pass data that you already have, the only piece of data you need to pass is an identifier for the option the user chose.

Lazarus
No, i want to get the values of each item in a listview.It goes like this:The user will input a keyword and the result of his search will be bind to a listview.Example of result is:1. Thesis Title: .... Author: ...... Batch: ....... Click to view the file (hyperlink)When the user clicks the link to view the file, I want to get the values of selected item. For example, I click result number 1, I want to get the value of thesis title, author. batch, etc. That's it.Thanks a lot.
Norbs
+1 That's more or less the answer I was going to add
PhilPursglove
A: 

There are a couple of ways to handle this depending on the amount of data you want to retrieve from the link.

1) As Lazarus mentions above, you can embed the ID or more details in the hyperlink.

2) The other option is to make the hyperlinks ListButtons with CommandArguments/CommandNames and handle the ListView.ItemCommand event in your codebehind. In this event you can then retrieve the details you want and redirect the user to your search result page with all of those in the URL, or do any other processing you may need to do.

Yobi21