473,413 Members | 1,833 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,413 software developers and data experts.

DropDownListBox and Item Value

I use the following piece of code to programatically insert an item into a
dropdownlistbox:

myDropdownListBox.items.insert(0, myDisplayedText)

This works but the value of the item is then the same as myDisplayedText.

My question: I want the value to be something different. How I can I
programmatically code the value of the item to be something different that
the displayed text?
Nov 19 '05 #1
3 1113
let me know if this helps
ListItem li= new ListItem();
li.Text ="a";
li.Value ="b";
DropDownList1.Items.Insert(0,li);

"Paul" wrote:
I use the following piece of code to programatically insert an item into a
dropdownlistbox:

myDropdownListBox.items.insert(0, myDisplayedText)

This works but the value of the item is then the same as myDisplayedText.

My question: I want the value to be something different. How I can I
programmatically code the value of the item to be something different that
the displayed text?

Nov 19 '05 #2
myDropdownListBox.Items.Insert(0,new ListItem("myDisplayedText","myValue"));
"Paul" wrote:
I use the following piece of code to programatically insert an item into a
dropdownlistbox:

myDropdownListBox.items.insert(0, myDisplayedText)

This works but the value of the item is then the same as myDisplayedText.

My question: I want the value to be something different. How I can I
programmatically code the value of the item to be something different that
the displayed text?

Nov 19 '05 #3
Yes, thank you.
"netdude" wrote:
let me know if this helps
ListItem li= new ListItem();
li.Text ="a";
li.Value ="b";
DropDownList1.Items.Insert(0,li);

"Paul" wrote:
I use the following piece of code to programatically insert an item into a
dropdownlistbox:

myDropdownListBox.items.insert(0, myDisplayedText)

This works but the value of the item is then the same as myDisplayedText.

My question: I want the value to be something different. How I can I
programmatically code the value of the item to be something different that
the displayed text?

Nov 19 '05 #4

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

Similar topics

2
by: Max | last post by:
Have a DropDownListBox where I want to give users the option to select one of the values, but allow them to enter a freeform text value if they choose to do so in lieu of the proffered values. Kind...
2
by: kgs | last post by:
I dynamically added a DropDownListBox to a footer of datagrid on itemcreated event. In which event in postback can i access the selected item. Interesting thing i noted that even though i create...
4
by: | last post by:
I think we have some bug in dropdownlistbox server control. Following are the values. <asp:DropDownList id="DropDownList1" runat="server"> <asp:ListItem value="46">INR</asp:ListItem>...
2
by: Mike | last post by:
I have a dropdownlistbox in a template column of a datagrid. I need to be able to respond to the selecteditemchanged event of the dropdownlist, but I am having trouble doing that. I thought I would...
1
by: raj | last post by:
hello i want to set the tooltip of data displaying in dropdownlistbox , i have bound the dropdownlistbox with datasource and i want that tooltip shld be display at every item of dropdownlistbox...
2
by: sharath | last post by:
sir, when i bind the dropdownlistbox through dataset, ok fine iget the datas. i have one command button and one label i want to display the selected item in label when i click button. but...
3
by: BenCoo | last post by:
Hi, I have a gridview control that displays data from 2 tabels in a sqlserver 2005 database. The table "Temperatures" has a field "LocationID" I populate the gridview with a ObjectDataSource...
2
by: Kenichi666 | last post by:
I am new to ASP.NET and C#. I have populate a dropdownlistbox from a sqltable. I would like to set the selected value in the dropdownlistbox to an sql UPDATE command. like fx. "UPDATE name =...
1
by: jeyapriya | last post by:
Dear Friends This is Jeyapriya. Right now I am working in the ASP.NET with VB coding & the back end is SQL SERVER 2000. My dilemma is I have to design a form with 2 DropDownListboxes. I have...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
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
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
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
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,...

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.