473,668 Members | 2,428 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 5970

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

Similar topics

8
22298
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 highlights the first item starting with the text in txtStreet. The listview contains 6,000 rows...
2
2994
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 click Save, the app displays a message box asking if they'd like to save their changes. This box...
9
3041
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
4017
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 item switches from the grey of being unfocused to the blue of focus. So far, so good.
4
4948
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 item switches from the grey of being unfocused to the blue of focus. So far, so good.
4
9042
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 after the population of the ListView so the item I was working on is selected again.. but then the...
2
6269
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 programs that have not been added to table yet. Ok, enough background. What is happening is if I use...
6
5536
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 disable if I click off the text of the items in the listview but still within about 10-20 pixels of...
4
13856
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 = True Listview1.Items(z).ForeColor = Blue
0
8382
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8802
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7405
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6209
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5682
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 into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4206
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2792
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2028
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1787
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.