473,503 Members | 9,912 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

list control and default to selected item?

Hi There,

I want to bind the value of a field from a database to make a dropdownlist
default to that value, I can't seem to get to work correctly. It just
doesn't seem work no matter what I do, could someone help me with some code?
Moe <><
lst1.SelectedItem.Value = Trim(dr("frm1value"))
<ASP:DropDownList id=lst1 name=lst1 maxlength= "40" runat=server>
<asp:ListItem Value="something">something</asp:ListItem>
<asp:ListItem Value="NO">NO</asp:ListItem>
<asp:ListItem Value="YES">YES</asp:ListItem>

</ASP:DropDownList>
Nov 18 '05 #1
1 1147
Hi,

I use this:
lst1.SelectedValue = myValue;

HTH,
Stefano Mostarda MCP
Rome Italy
Moe Sizlak wrote:
Hi There,

I want to bind the value of a field from a database to make a dropdownlist
default to that value, I can't seem to get to work correctly. It just
doesn't seem work no matter what I do, could someone help me with some code?
Moe <><
lst1.SelectedItem.Value = Trim(dr("frm1value"))
<ASP:DropDownList id=lst1 name=lst1 maxlength= "40" runat=server>
<asp:ListItem Value="something">something</asp:ListItem>
<asp:ListItem Value="NO">NO</asp:ListItem>
<asp:ListItem Value="YES">YES</asp:ListItem>

</ASP:DropDownList>

Nov 18 '05 #2

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

Similar topics

8
2731
by: sara | last post by:
I am learning Access and programming. I wanted to have the user select the departments for an ad from the list of all departments. Found code (that I could understand) on this site, and it works....
2
7799
by: Chris | last post by:
I was wondering if there was any way to add a blank list item control to the beginning of the System.Web.UI.WebControls.DropDownList's datasource after the control's datasource has been specified....
5
10798
by: Kris Rockwell | last post by:
Hello (again), I have gotten the dropdown list functionality to work through a few tricks (probably not the most efficient, but it works) but I am not sure how to set the default selected value....
6
10653
by: Mark | last post by:
I have two dropdown lists. Both have autopostback set to true. In both dropdowns, when you select an item from the list, it redirects to the Value property of the dropdown. Nothing fancy. ...
2
2257
by: Peter | last post by:
Hello! Please, could anyone tell, is it possible to set multiple items to be selected in list control in the code? For example when the web form is loaded three items of 5 are selected in list...
2
8594
by: clickon | last post by:
I am using ASP.net 2.0 and trying to take advantage of the updated data editing facilities provided through the SQLDataSource control and the DetailsView control. The data is a record from a...
0
2895
by: cindy | last post by:
I have a dynamic datagrid. I have custom classes for the controls public class CreateEditItemTemplateDDL : ITemplate { DataTable dtBind; string strddlName; string strSelectedID; string...
0
3662
by: Paul Hadfield | last post by:
I'm looking for thoughts on the "correct" design for this problem (DotNet 2.0 - in winforms, but that's not so important). I've got two combo boxes (combo1 and combo2), both are populating via...
4
1159
by: Aussie Rules | last post by:
Hi, I have a drop down that I have populated. I am use to using winforms with the items.add function to add objects to the drop downs, but on web forms it seems you can only add text string. ...
0
7207
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
7095
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...
0
7294
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
7361
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...
1
7015
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
7470
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...
0
5602
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
3183
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...
0
403
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...

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.