Asp tutorial. net: assign a value to dropdownlist
Every option in the dropdownlist control is defined by the listitem element!
Tip: This control supports data binding!
Attribute
Property Description. net
Selectedindex option 1.0
Onselectedindexchanged the name of the function executed when the index of the option is changed. 1.0
Runat specifies that the control is a server control. Must be set to "server ". 1.0
Listcontrol standard attributes
Appenddatabounditems, autopostback, causesvalidation, datatextfield,
Datatextformatstring, datavaluefield, items, runat, selectedindex, selecteditem,
The selectedvalue, tagkey, text, validationgroup, and onselectedindexchangedlistcontrol controls include all the basic functions of the list control. Controls inherited from this control include: checkboxlist, dropdownlist, listbox, and radiobuttonlist.
For a complete description, visit the standard attributes of listcontrol.
Standard properties of web controls
Accesskey, attributes, backcolor, bordercolor, borderstyle, borderwidth,
Css tutorial class, enabled, font, enabletheming, forecolor, height, isenabled,
For a complete description of skinid, style, tabindex, tooltip, and width, visit the standard properties of the web control.
Standard properties
Apprelativetemplatesourcedirectory, bindingcontainer, clientid, controls,
Enabletheming, enableviewstate, id, namingcontainer, page, parent, site,
Templatecontrol, templatesourcedirectory, uniqueid, and visible. For a complete description, visit the standard properties of the control.
Assign a value to combobox in winform. In winform, combobox obtains the selectedvalue supplement of the bound object set.
On the asp.net tutorial page, assign a value to dropdownlist as follows:
Dptype. selectedindex = dptype. items. indexof (dptype. items. findbytext (m_tradereport.r_catename ));
Or
Dptype. selectedindex = dptype. items. indexof (dptype. items. findbyvalue (m_tradereport.r_cateid ));
These two methods can avoid the following situations where values cannot be set:
Dptype. selectedvalue = convert. tostring (m_tradereport.r_cateid );
Obtain the selected value for dropdownlist:
Try {m_tradereport.r_cateid = sqlparser. intparse (dptype. selectedvalue); m_tradereport.r_catename = sqlparser. stringparse (dptype. selecteditem. text);} catch {}
Or
M_tradereport.r_cateid = sqlparser. intparse (request [dptype. clientid]);