473,507 Members | 2,389 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

leading space in dropdownlist

TJS
I am populating a droplist control from a query.

each line of content in the dropdownlist gets "trimmed" automatically .
how can I force a leading space to a line in a dropdown list ??
Nov 18 '05 #1
4 4315
TJS,

Here's how:

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

DropDownList1.Items.Add(Pad(5) & "Item: 1")

End Sub

Private Function Pad(ByVal numberOfSpaces As Int32) As String
Dim Spaces As String

For items As Int32 = 1 To numberOfSpaces
Spaces &= " "
Next

Return Server.HtmlDecode(Spaces)
End Function
--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"TJS" <no****@here.com> wrote in message
news:ev**************@tk2msftngp13.phx.gbl...
I am populating a droplist control from a query.

each line of content in the dropdownlist gets "trimmed" automatically .
how can I force a leading space to a line in a dropdown list ??

Nov 18 '05 #2
The code below has worked for me in the past

--
Regards

John Timney
Microsoft Regional Director
Microsoft MVP
----------------------------------------------------------------------------
------------------------------------
<blatant plug>
Professional .NET for Java Developers with C#- ISBN: 1-861007-91-4
Professional Windows Forms - ISBN: 1861005547
Professional JSP 2nd Edition - ISBN: 1861004958
Professional JSP - ISBN:
1861003625
Beginning JSP Web Development - ISBN: 1861002092
</blatant plug>
----------------------------------------------------------------------------
------------------------------------

<%@ Page Language="VB" Debug="true" %>
<script language=VB runat=server>

Sub Page_Load(Sender As Object, E As EventArgs)

Dim Padding As String
Dim writer As New System.IO.StringWriter()
Dim DecodedString As String

Padding = "&nbsp;&nbsp;"
Server.HtmlDecode(Padding, writer)
Padding = writer.ToString()

myDropDownList2.Items.Add(Padding & " MVP's")

Padding = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb sp;"
Server.HtmlDecode(Padding, writer)
Padding = writer.ToString()

myDropDownList2.Items.Add(Padding & " MVP's")

myDropDownList2.Items.Add("MVP's" & Padding & "Do Their best")
End Sub

</script>
<html>
<head><title>Padding DropListBox</title></head>

<body>

<form fred runat="server">

<asp:dropdownlist
id="MyDropDownList2"
runat="server"
/>

</form>

</body>
</html>


"TJS" <no****@here.com> wrote in message
news:ev**************@tk2msftngp13.phx.gbl...
I am populating a droplist control from a query.

each line of content in the dropdownlist gets "trimmed" automatically .
how can I force a leading space to a line in a dropdown list ??

Nov 18 '05 #3
add: &nbsp;
This is means Non-Breaking Space in HTML

Nov 18 '05 #4
Moshitch,

Just for future knowledge &nbsp; gets trimmed too.

You have to encode it to get it to work.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

Free code library at:
www.aboutfortunate.com

"Out of chaos comes order."
Nietzche
"Moshitch" <an*******@discussions.microsoft.com> wrote in message
news:6F**********************************@microsof t.com...
add: &nbsp;
This is means Non-Breaking Space in HTML

Nov 18 '05 #5

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

Similar topics

6
16151
by: Grumble | last post by:
Hello all, I want to read lines from a text file, where each line has the following syntax: token1:token2:token3 There could be white space between tokens and ':'
0
1407
by: Leo | last post by:
Can the value of the union datatype contain leading/trailing white space if it's not allowed by the member datatypes? For example, in the following example: t1.xsd: <?xml version="1.0"?>...
5
3113
by: Walter Tross | last post by:
Somebody with a very regulatory mind in this newsgroup has written that it's better not to use a leading underscore for class member names, because names with a leading underscore are used...
1
1053
by: TJS | last post by:
I am populating a dropdownlist control from a query. Each line of content in the dropdownlist may get modified with a leading text character as a flag before being added to the list. how can I...
3
2240
by: Jon Sagara | last post by:
I'm trying to insert space characters into some ListItems in a DropDownList. However, ASP.NET is converting my "&nbsp;" into "&amp;nbsp;". Anyone know how to insert literal spaces when populating a DDL...
4
6036
by: Steve Richter | last post by:
when I run the following code the leading spaces of the "data" node are removed. How do I retain whitespace? private void CreateBasicXmlDocument() { XmlWriterSettings writeSettings = new...
5
2554
by: Richard Maher | last post by:
Hi, Can someone please show me how to tell Firefox to preseve white-space when returning the selectList.option.value attribute? I have change the style so that the white-space is preserved on...
2
1612
by: Joseph J. Kesselman | last post by:
Gabe wrote: You can do exactly that, exactly as you've shown it: <nameJohn Smith</name> But... Now you aren't talking about XML -- you're talking about the behavior of the tool you're...
5
3247
by: danield | last post by:
Hello All, I have a query that I use to create another table: SELECT column1 & " " & column2 INTO table2 FROM table1 The problem is that sometimes there is no value in column1 and then...
0
7223
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
7321
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
7377
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
7034
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
5623
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,...
1
5045
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3191
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
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
412
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.