473,398 Members | 2,188 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Finding item in dropdownlist

When initializing form (form load) I have

lstRadiator.Items.FindByValue("5").Selected = True

So when the page is shown in the browser, why doesn't it show option
value #5 on the list? It just keep showing the first item ("999")...?

Looking the code from browser:

<select name="lstRadiator" id="lstRadiator"
title="Choose item" style="font-size:Smaller;width:115px;">
<option value="999">--Choose --</option>
<option value="1">De Longhi</option>
<option value="2">Demrad</option>
<option value="3">Eurorad</option>
<option value="16">Hudevad</option>
<option value="5">Ludvig</option>
<option value="6">Mari</option>
<option value="7">Purmo</option>
<option value="8">Rio</option>
<option value="12">Thor</option>
<option value="15">Veha</option>
<option value="1000">--&gt; Other &lt;--</option>

Regards /Snedker
Jan 21 '07 #1
2 1021
Morten,

Placing the following code into the Page_Load event seems to work properly
for me:

lstRadiator.Items.FindByValue("5").Selected = true;

The only difference in my code is that you are missing a runat="server"
attribute in your select element. Could this be your problem?
"Morten Snedker" <morten_spammenot_ATdbconsult.dkwrote in message
news:5b********************************@4ax.com...
When initializing form (form load) I have

lstRadiator.Items.FindByValue("5").Selected = True

So when the page is shown in the browser, why doesn't it show option
value #5 on the list? It just keep showing the first item ("999")...?

Looking the code from browser:

<select name="lstRadiator" id="lstRadiator"
title="Choose item" style="font-size:Smaller;width:115px;">
<option value="999">--Choose --</option>
<option value="1">De Longhi</option>
<option value="2">Demrad</option>
<option value="3">Eurorad</option>
<option value="16">Hudevad</option>
<option value="5">Ludvig</option>
<option value="6">Mari</option>
<option value="7">Purmo</option>
<option value="8">Rio</option>
<option value="12">Thor</option>
<option value="15">Veha</option>
<option value="1000">--&gt; Other &lt;--</option>

Regards /Snedker
Jan 22 '07 #2
On Sun, 21 Jan 2007 19:04:09 -0500, "Page Brooks"
<pa********@gmail.comwrote:
All is well. I tried to select from the list before anything was in
it. Somehow Microsoft still fails at meeting my shortcomings. ;-)

Thanks for your replay anyway!

Regards /Sendker
Jan 22 '07 #3

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

Similar topics

7
by: localhost | last post by:
A DataGrid with shows a label in one of the columns when in view mode. When in edit mode, I want to show a dropdown, and have the default selection set to what the textbox used to be. Right now...
3
by: Tim::.. | last post by:
Can someone please tell me how I go about preselecting an item in a drop drown list when I click the Edit Command in a datagrid? I have tried the following but it doesn't work for me! I would...
4
by: Chris | last post by:
Using: DataGrid1_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles DataGrid1.ItemCommand is there a way to find a specific item in the...
3
by: Sam C | last post by:
Hi, I have an ASP.Net page which has a DropDownList on it. The DDL is populated via a method which is called from the Page_Load if IsPostBack = False. When the form is submitted the...
15
by: glenn | last post by:
Hi folks, I have a DropDownList in a DataGrid that is populated from records in a database. I want to add a value that might be a string such as "Select a Company" for the first item since an...
3
by: Iain | last post by:
Hi All I have 2 DropDownList boxes on a page. The first (id= "Operation") is populated on PageLoad with the contents of a database table. The second id="WorkStations" will not be populated...
0
by: Carlos | last post by:
Hi all, I have a hyperlink pointing to a page that contains a dropdownlist. This dropdown is loaded using a datatable when the page is loaded. However, I would like the hyperlink to point to the...
6
by: yasodhai | last post by:
Hi, I used a dropdown control which is binded to a datagrid control. I passed the values to the dropdownlist from the database using a function as follows in the aspx itself. <asp:DropDownList...
3
by: Lohboy | last post by:
Using ASP.NET and IE7. (Sorry if I am posting in the wrong forum but my problem seemed to be more related to the JavaScript side than the ASP.NET side.) I have two DropDownList controls the...
6
by: RobertTheProgrammer | last post by:
Hi folks, Here's a weird problem... I have a nested GridView setup (i.e. a GridView within a GridView), and within the nested GridView I have a DropDownList item which has the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
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...
0
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...
0
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,...
0
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...

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.