开发者

how to get the selected item from a listview after a link has been clicked?

开发者 https://www.devze.com 2022-12-14 00:55 出处:网络
I have a problem regarding listview control in asp.net and vb.net. I\'m developing a web based application wherein the user开发者_Python百科 will search for a topic and the search results will be disp

I have a problem regarding listview control in asp.net and vb.net. I'm developing a web based application wherein the user开发者_Python百科 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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消