all groups > asp.net webcontrols > february 2006 >
You're in the

asp.net webcontrols

group:

How to indent a dropdownlist


How to indent a dropdownlist Neel
2/27/2006 2:16:40 PM
asp.net webcontrols:
Hi
How do we indent the data in the dropdownlist?
Thanks
-Avijit

RE: How to indent a dropdownlist stcheng NO[at]SPAM online.microsoft.com
2/28/2006 12:00:00 AM
Hi Avijit,

Welcome to the ASP.NET newsgroup.

As for the DropDownList control, it actually render as html <select>
element in client browser and each of the Items will be rendered as html
<option> sub element. If we want to make the data text displayed with some
indents, we need to put some html space --- &nbsp;(or &#160;) --- in front
of the text. For example:

<asp:DropDownList ID="DropDownList3" runat="server" >
<asp:ListItem >&#160;&#160;Item1</asp:ListItem>
<asp:ListItem>&#160;&#160;Item2</asp:ListItem>
<asp:ListItem>&#160;&#160;Item3</asp:ListItem>
<asp:ListItem>&#160;&#160;Item4</asp:ListItem>

</asp:DropDownList>

If you're using Databinding to populate the dropdownlist, we need to make
sure the datasource's Text property has already contains the html space
element in it.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)



Re: How to indent a dropdownlist Ken Cox - Microsoft MVP
3/1/2006 4:05:58 PM
Hi Steven,

I don't see a way for the ASP.NET dropdownlist control to support the
optgroup functionality. Is there a way to make it generate this HTML?

<select>
<optgroup label="Alkaline Metals">
<option>Lithium (Li)</option>
<option>Sodium (Na)</option>
<option>Potassium (K)</option>
</optgroup>
<optgroup label="Halogens">
<option>Fluorine (F)</option>
<option>Chlorine (Cl)</option>
<option>Bromine (Br)</option>
</optgroup>
</select>

Ken
Microsoft MVP [ASP.NET]


[quoted text, click to view]

Re: How to indent a dropdownlist stcheng NO[at]SPAM online.microsoft.com
3/2/2006 1:40:32 AM
Hi Ken,

I don't think ASP.NET dropdownlist support the option group you mentioned.
Also, for most customization on dropdownlist's rendered data, what we can
do is focus on the datasource rather than the list itself.

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
AddThis Social Bookmark Button