Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > ASP.NET 4 General Discussion
|
ASP.NET 4 General Discussion For ASP.NET 4 discussions not relating to a specific Wrox book
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 4 General Discussion section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old May 31st, 2012, 10:54 AM
Authorized User
 
Join Date: Mar 2012
Posts: 59
Thanks: 2
Thanked 4 Times in 4 Posts
Default Identify ListViewItem Record Being Clicked On?

Hi All,

I need some help once again.

I have a ListView control which all works fine with Edit & Delete command buttons in the ItemTemplate. This gathers basic text information regarding a review. However I have also added an additional button to the ItemTemplate which is used to re-direct users to another page to add related pictures for the specific ID which relates to the current ListViewItem's ID. i.e an individual review with multiple pictures.

I want to do this by using a QueryString from the ListViewItem button that is clicked to specify the ID of the record that the pictures need to be added to. Seems simple, however, what I cannot seem to get right is the SelectedIndex of the ListViewItem that has been clicked (when I click my own button) so that I can identify the value of the ID to be passed in the QueryString.

I have added sample code and when I click my manually created button in the ListViewItem the SelectedIndexChanged event is not raised so I am not sure what I can evaluate to get the ID efficiently?

I have actually got round this issue by binding the ID of each record to the ValidationGroup property of each button in the ListViewItem when the ListView is created (exactly the same as you use the tag property in straight VB/C# coding) which I can then evaluate and pass to the QueryString but what I realise is that there must be a more efficient and better way to do this?

Can anyone help?

Kind regards,

Ian Ryder.
 
Old May 31st, 2012, 11:26 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Ian,

If you're redirecting with an ID in the query string, why not use a client side <a> element with the ID embedded in the URL?

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old June 1st, 2012, 12:30 AM
Authorized User
 
Join Date: Mar 2012
Posts: 59
Thanks: 2
Thanked 4 Times in 4 Posts
Default Combining Tuition and Knowledge

Hi Imar,

Thanks for the easy and obvious solution to my question.

Everything works great using an <a> element and then binding the ID to the href attribute of the element.

It feels a bit like a school boy error but I put this one down to still learning and needing to step back once in a while to see what can be done easily based on what I have learnt. The jigsaw puzzle is starting to fall into place?

Cheers,

Ian.
 
Old June 3rd, 2012, 05:29 AM
Imar's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Quote:
The jigsaw puzzle is starting to fall into place?
Excellent. That's good to hear....

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!

Last edited by Imar; June 3rd, 2012 at 05:32 AM..





Similar Threads
Thread Thread Starter Forum Replies Last Post
ListViewitem in VB.Net 2005 johnnys14 Classic ASP Databases 2 July 11th, 2008 02:09 PM
Vb.Net 2005 and listviewitem problem johnnys14 ADO.NET 0 July 10th, 2008 01:18 PM
Radio button / ListViewItem Help Bee95 VB.NET 2002/2003 Basics 0 December 12th, 2006 11:27 PM
How to know/identify that installation is done shiby_chacko1@rediffmail. C# 1 March 30th, 2005 03:21 AM
How to identify the computer Name MuthuAL Classic ASP Databases 2 December 22nd, 2004 08:42 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.