Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > leading space in dropdownlist

Reply
Thread Tools

leading space in dropdownlist

 
 
TJS
Guest
Posts: n/a
 
      02-11-2004
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 ??


 
Reply With Quote
 
 
 
 
John Timney \(Microsoft MVP\)
Guest
Posts: n/a
 
      02-11-2004
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" <> wrote in message
news:...
> 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 ??
>
>



 
Reply With Quote
 
 
 
 
S. Justin Gengo
Guest
Posts: n/a
 
      02-11-2004
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 &= "&nbsp;"
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" <> wrote in message
news:...
> 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 ??
>
>



 
Reply With Quote
 
=?Utf-8?B?TW9zaGl0Y2g=?=
Guest
Posts: n/a
 
      02-11-2004
add: &nbsp;
This is means Non-Breaking Space in HTML

 
Reply With Quote
 
S. Justin Gengo
Guest
Posts: n/a
 
      02-11-2004
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" <> wrote in message
news:6FBBA011-7686-49EE-BA18-...
> add: &nbsp;
> This is means Non-Breaking Space in HTML
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
All leading tabs or all leading spaces - why isn't that enforced? John Nagle Python 4 08-07-2007 04:05 PM
RE: All leading tabs or all leading spaces - why isn't that enforced? Delaney, Timothy (Tim) Python 0 08-07-2007 03:50 AM
Why Python style guide (PEP-8) says 4 space indents instead of 8 space??? 8 space indents ever ok?? Christian Seberino Python 21 10-27-2003 04:20 PM
Re: Why Python style guide (PEP-8) says 4 space indents instead of8 space??? 8 space indents ever ok?? Ian Bicking Python 2 10-23-2003 07:07 AM
Stack space, global space, heap space Shuo Xiang C Programming 10 07-11-2003 07:30 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57