473,574 Members | 3,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ListView Selected Item Not Working

I have a listview that when I select an item, it populates a details view. I
want to show the item that was selected in the listview by changing it to
yellow. Trouble is, the selected item does not show as yellow until I've
clicked the same item two times. What am I doing wrong on the selected item
that keeps it from changing to yellow until the item is clicked two times?
Also, I have to set the listviews selectedIndex in the SelectedIndexCh anging
event. Not sure if this is related to the color problem, but is that what you
are supposed to do?

<asp:ListView ID="lvSearchRes ults" DataKeyNames="M emberID"
OnDataBound="lv SearchResults_D ataBound"
OnSelectedIndex Changing="lvSea rchResults_Sele ctedIndexChangi ng"
OnSelectedIndex Changed="lvSear chResults_Selec tedIndexChanged " runat="server">
<ItemTemplate >
<div id="Div1" style="text-align: left; border: solid 1px gray;
background-color: #F7F6F3; color: #333333; position: relative;"
runat="server">
<h5 style="display: inline;">
Member ID:
</h5>
<asp:Label ID="MemberIDLab el" runat="server" Text='<%# Eval("MemberID" )
%>' />
<br />
<h5 style="display: inline;">
Name:
</h5>
<asp:Label ID="FullnameLab el" runat="server" Text='<%# Eval("FullName" )
%>' />
<br />
<h5 style="display: inline;">
State/Postal Code:
</h5>
<asp:Label ID="StateCodeLa bel" runat="server" Text='<%# Eval("State") %>'
/>
/
<asp:Label ID="PostalCodeL abel" runat="server" Text='<%#
Eval("PostalCod e") %>' />
<br />
<h5 style="display: inline;">
Home Phone:
</h5>
<asp:Label ID="HomePhoneNu mberLabel" runat="server" Text='<%#
Eval("PhoneNumb er") %>' />
<br />
<asp:CheckBox ID="ActionFlagC heckBox" runat="server" Checked='<%#
Eval("ActionFla g") %>'
Enabled="false" Style="font-weight: bold;" Text="Action Flag" />
<asp:ImageButto n ID="btnSelect" Style="position : absolute; bottom: 2px;
right: 2px;" CommandName="Se lect" ImageUrl="~/Images/Buttons/s_select_0.png"
tooltip="Submit this search criteria" runat="server" />
</div>
</ItemTemplate>
<AlternatingIte mTemplate>
<div id="Div2" style="text-align: left; border: solid 1px gray;
background-color: #FFFFFF; color: #333333; position: relative;"
runat="server">
<h5 style="display: inline;">
Member ID:
</h5>
<asp:Label ID="MemberIDLab el" runat="server" Text='<%# Eval("MemberID" )
%>' />
<br />
<h5 style="display: inline;">
Name:
</h5>
<asp:Label ID="FullnameLab el" runat="server" Text='<%# Eval("Fullname" )
%>' />
<br />
<h5 style="display: inline;">
State/Postal Code:
</h5>
<asp:Label ID="StateCodeLa bel" runat="server" Text='<%# Eval("State") %>'
/>
/
<asp:Label ID="PostalCodeL abel" runat="server" Text='<%#
Eval("PostalCod e") %>' />
<br />
<h5 style="display: inline;">
Home Phone:
</h5>
<asp:Label ID="HomePhoneNu mberLabel" runat="server" Text='<%#
Eval("PhoneNumb er") %>' />
<br />
<asp:CheckBox ID="ActionFlagC heckBox" runat="server" Checked='<%#
Eval("ActionFla g") %>'
Enabled="false" Style="font-weight: bold;" Text="Action Flag" />
<asp:ImageButto n ID="btnSelect" Style="position : absolute; bottom: 2px;
right: 2px;" CommandName="Se lect" ImageUrl="~/Images/Buttons/s_select_0.png"
tooltip="Submit this search criteria" runat="server" />
</div>
</AlternatingItem Template>
<LayoutTemplate >
<div id="itemPlaceho lder" style="text-align: center; background-color:
#CCCCCC; font-family: Verdana, Arial, Helvetica, sans-serif;
color: #000000;" runat="server">
</div>
</LayoutTemplate>
<SelectedItemTe mplate>
<div id="Div3" style="text-align: left; border: solid 1px gray;
background-color: #FFFF99; color: #333333;" runat="server">
Member ID:
<asp:Label ID="MemberIDLab el" runat="server" Text='<%# Eval("MemberID" )
%>' />
<br />
Name:
<asp:Label ID="FullnameLab el" runat="server" Text='<%# Eval("Fullname" )
%>' />
<br />
State/Postal Code:
<asp:Label ID="StateCodeLa bel" runat="server" Text='<%# Eval("State") %>'
/>
/
<asp:Label ID="PostalCodeL abel" runat="server" Text='<%#
Eval("PostalCod e") %>' />
<br />
Home Phone:
<asp:Label ID="HomePhoneNu mberLabel" runat="server" Text='<%#
Eval("PhoneNumb er") %>' />
<br />
<asp:CheckBox ID="ActionFlagC heckBox" runat="server" Checked='<%#
Eval("ActionFla g") %>'
Enabled="false" Text="Action Flag" />
<br />
</div>
</SelectedItemTem plate>
<ItemSeparatorT emplate>
<br />
</ItemSeparatorTe mplate>
</asp:ListView>
protected void lvSearchResults _SelectedIndexC hanging(object sender,
ListViewSelectE ventArgs e)
{
lvSearchResults .SelectedIndex = e.NewSelectedIn dex;
}

<asp:ObjectData Source ID="odsQuickDet ails" runat="server"
OldValuesParame terFormatString ="original_{ 0}"
SelectMethod="G etQuickDetails" TypeName="App_C lasses.Members" >
<SelectParamete rs>
<asp:ControlPar ameter ControlID="lvSe archResults" Name="MemberID"
PropertyName="S electedValue" Type="String" />
</SelectParameter s>
</asp:ObjectDataS ource>

Aug 12 '08 #1
0 5951

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
22288
by: Jon Ripley | last post by:
Using VB6 (for two weeks!) I could get a ListBox search working perfectly but with a ListView it has completely stumped me. I've not found any previous posts that have helped :( The user enters a string into a text box (txtStreet) and as they type any matching entry in the listview (lsvStreets) is highlighted and made visible. The search...
2
2988
by: David Anderson | last post by:
I'm working on a Windows app that has a ListView containing a bunch of items. When the user clicks on an item, the app displays the item'd details. The user then has the opportunity to edit these details. The user should click the Save button after each change, but of course that doesn't always happen. If the user makes changes and doesn't...
9
3037
by: Devron Blatchford | last post by:
Hi there, Just wondering if I change the back and fore colour of a listview item when the mouse hovers over it? I want to overide the default windows colour. Can someone please tell me how to do this? Thanks Devron
1
4005
by: Shane | last post by:
I have a text box select items in a listview as text is being typed into the text box. I get the select bar to move correctly in the Listview control. If the user presses the down or up key in the text box, I want to move to the selected item in the listview box. The down or up arrow does set focus to the listview box and the selected...
4
4934
by: Shane | last post by:
I have a text box select items in a listview as text is being typed into the text box. I get the select bar to move correctly in the Listview control. If the user presses the down or up key in the text box, I want to move to the selected item in the listview box. The down or up arrow does set focus to the listview box and the selected...
4
9041
by: Lars Netzel | last post by:
I have a long list of Items in a ListView... if I scroll down to something that is not visible without scrolling and then click on it I open another window where you can work with the details of that item.. Then I close that window I repopulate the ListView to reflect some changes make in the details window.. and I re-set the selected Row...
2
6266
by: Mike | last post by:
Ok I'm having a problem with a listview. I have a listview on a WinForm called ProgramInformationFrm. I call this from from 2 other forms. One is ProgramSearch Frm, the other is OpenNCFrm. The search form accepts criteria from a user ans searches a sql table for any nc program that matches the criteria. The open form gives the user a list of...
6
5520
by: Brandon McCombs | last post by:
Hello, I have a form that contains a listview on the left side and a column of buttons on the right side. Only some of the buttons do I want enabled all the time. The other buttons should be enabled only if something is selected in the listview. That part specifically works but not very well. It seems that I can only get the buttons to...
4
13844
by: Bill-R | last post by:
I'm trying to convert a vb6 program to vb.net (vb2008 express) I have text data in a Listview Control I use a Textbox to enter characters to search the Listview When a Match is found, I use textbox_textchanged to select listview item Listview1.Items(z).Selected = True Listview1.Items(z).EnsureVisible () Listview1.Items(z).FullRowSelect...
0
7805
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7726
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8052
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8234
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7815
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8098
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5620
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5300
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3740
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.