473,785 Members | 2,283 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding attributes to items in a dropdown list

Hey again,

Anybody have any ideas about how I would go about adding attributes to the
listitems in a databound dropdownlist?

Asp.net debugger has kindly informed me that dropdown list is not a
collection so that 'for each listitem in dropdownlist' style code won't
work.

Joe
Nov 18 '05 #1
3 2630
Hi...

Use HtmlSelect control instead of DropDownList...

"Joe Molloy" <mo********@hot mail.com> wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
Hey again,

Anybody have any ideas about how I would go about adding attributes to the
listitems in a databound dropdownlist?

Asp.net debugger has kindly informed me that dropdown list is not a
collection so that 'for each listitem in dropdownlist' style code won't
work.

Joe

Nov 18 '05 #2
That kinda takes from the convenience of the databinding - I don't want to
have to loop through and add values - does anyone know off the top of their
heads is there an onItemCreate method like that for datalists and datagrids?

Joe
"Eugene Jenihov" <eu****@dotsite .spb.ru> wrote in message
news:O8******** ******@TK2MSFTN GP11.phx.gbl...
Hi...

Use HtmlSelect control instead of DropDownList...

"Joe Molloy" <mo********@hot mail.com> wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
Hey again,

Anybody have any ideas about how I would go about adding attributes to the listitems in a databound dropdownlist?

Asp.net debugger has kindly informed me that dropdown list is not a
collection so that 'for each listitem in dropdownlist' style code won't
work.

Joe


Nov 18 '05 #3
There is an event fired by DataGrids called ItemDataBound. You might
be able to catch this event and then add your attribute there.

Neil

"Joe Molloy" <mo********@hot mail.com> wrote in message news:<Ok******* *******@tk2msft ngp13.phx.gbl>. ..
That kinda takes from the convenience of the databinding - I don't want to
have to loop through and add values - does anyone know off the top of their
heads is there an onItemCreate method like that for datalists and datagrids?

Joe
"Eugene Jenihov" <eu****@dotsite .spb.ru> wrote in message
news:O8******** ******@TK2MSFTN GP11.phx.gbl...
Hi...

Use HtmlSelect control instead of DropDownList...

"Joe Molloy" <mo********@hot mail.com> wrote in message
news:u8******** ******@TK2MSFTN GP12.phx.gbl...
Hey again,

Anybody have any ideas about how I would go about adding attributes to the listitems in a databound dropdownlist?

Asp.net debugger has kindly informed me that dropdown list is not a
collection so that 'for each listitem in dropdownlist' style code won't
work.

Joe


Nov 18 '05 #4

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

Similar topics

5
2921
by: Tim | last post by:
I have block of code adding values to dropdown list under if (!Page.IsPostBack) { adding items } else { refreshing data }
4
5482
by: DotNetJunky | last post by:
I have built a control that runs an on-line help system. Depending on the category you selected via dropdownlist, it goes out and gets the child subcategories, and if there are any, adds a new dropdownlist to the screen for selection. This continues until there are no children, and then it checks for a help article list based on that last selection and displays actual articles for display. Adding the controls and getting everything...
0
5414
by: Frawls | last post by:
Hi, This is concerned with System.Web.UI.WebControls.DropDownList I am having problems creating a method which will remove list items from a preloaded dropdownlist. This dropdown is loaded when the page loads and the items are pulled from a database. I want to create a method which is called on the page load and will remove certain items from the dropdown list. I want the method to loop
5
11458
by: Kay | last post by:
Hello, I have two list boxes on my form, one initially displays with items and the other displays blank, by clicking a button, it is possible to move items from one box to another and vice a versa, this works fine. I also have a dropdown list on the page with autopost back = true, my problem is as follows: when the user selects an option in the dropdown list the form is posted back to the server and certain other processing happens, then...
2
3049
by: Shiju Poyilil | last post by:
Hi ! I have a requirement wherein i am binding a datalist which contains a label (Caption for the field) and some literal hidden fields and a dropdown list. When I am binding to the datalist.. only the labels (caption) and the invisible literal controls are binded.. Now based on the invisible literal control values I get the information from DB to bind it with each dropdown list (I am doing this in the item databound event) Also based on...
2
1458
by: estafford | last post by:
I have a dropdownlist control that is filled using a database query. I also want to add an additional option to the list that is not pulled from the database. How can I go about doing that? I've tried adding a list item to the control, but that seems to be overwritten by the databinding. Thanks for any help ES
2
1591
by: Bruno Alexandre | last post by:
Hi guys, I'm using Javascript to dynamically add to a dropdown values like for ( i=0; i<tv.length; i++ ) { selectDDAvisCtrl.options = new Option(tv, tv); } and I use document.getElementById("ddAvis").options.innerHTML;
0
1130
by: JP | last post by:
I have a .NET Dropdown list control that get populated with several ITEMS from a database. In addition, each of those items get populated with additional attributes via this syntax: (assume that items exist) dropAliasNames.Items.Attributes.Add("FN",123); dropAliasNames.Items.Attributes.Add("LN",482); The issue is that on a post back, the items are in the list of course but all attributes added before the post back are gone, Why? I can...
1
7766
by: mitchman10 | last post by:
My Time table has TimeID,Employee,PayPeriod,ChargeCodeID,Hours My Chargecode table has ChargecodeID,c_Text I need an Editable datagrid that will show the TimeID,Employee,PayPeriod,C_Text in a label and hours, along with an edit linkbutton. When they click on edit, the edit button turns to Update Cancel TimeID stays read Only
0
9643
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9480
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
10147
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...
1
10083
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 most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
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...
0
5379
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...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
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
3
2877
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.