Problem: Can't pad spaces in dropdownlist

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Re: Problem: Can't pad spaces in dropdownlist

    have you tried the HTML space character?
    "   &nbsp"

    "VB Programmer" <growNO-SPAM@go-intech.com> wrote in message
    news:uH8OGMRXDHA.536@TK2MSFTNGP10.phx.gbl...
    > I have a ddl that is based on data from a datareader. Between column 0 and
    > column 1 I wanted to pad it with 15 spaces.
    >
    > Problem is it keeps only putting 1 space in between the columns! Any
    ideas?
    >
    > Here's a snippet...
    > drReader = cmdSqlCmd.ExecuteReader
    >
    > ' loop through reader and populate offices
    > Do While drReader.Read()
    > ddlOffice.Items.Add(drReader.GetString(0) & " " &
    _
    > drReader.GetInt32(1))
    > Loop
    >
    >

    Mark MacRae Guest

  2. Similar Questions and Discussions

    1. EditItemTemplate's DropDownList problem
      I have follow the instruction from the web. http://aspnet.4guysfromrolla.com/demos/dgExample16.aspx When I was trying to implement new codes in...
    2. DropDownList problem
      Hi, I have a WebForm on which I have 2 buttons: "Retreive" and "Insert" When I push "Retreive" I would like to retreive info from my DataBase and...
    3. Problem with a DropDownList in a WebControl
      I created a webcontrol with inside a dropdownlist, and exposed its proprieties DataSource,DataMember,DataTextField,DataValueField But I can't set...
    4. problem with dropdownlist selected item
      I'm having the problem with this drop down list on postback. For some reason both the ListItems get selected when I change the selected item. Using...
    5. Inherited DropDownList Designer problem
      I have an inherited DropDownList custom control that in the DataBind() method I add a bunch pre determined list items that contain the various...
  3. #2

    Default Re: Problem: Can't pad spaces in dropdownlist

    This has worked for me before, but its IE only I think. You could hold the
    number of spaces required in your web.config file instead of the actual
    spaces

    Dim EncodedString As String = "This is a Test
    String&#160;&#160;&#160;&#160;EndTestString"
    Dim writer As New System.IO.StringWriter()
    Server.HtmlDecode(EncodedString, writer)
    Dim DecodedString As String = writer.ToString()
    lstTest.Items.Add(DecodedString)

    --
    Regards

    John Timney (Microsoft ASP.NET MVP)
    ----------------------------------------------
    <shameless_author_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
    </shameless_author_plug>
    ----------------------------------------------

    "VB Programmer" <growNO-SPAM@go-intech.com> wrote in message
    news:ec0S1ZRXDHA.2204@TK2MSFTNGP12.phx.gbl...
    > That padding is actually in a <appSettings> variable in my Web.config.
    > Right now it was...
    > <appSettings>
    > <add key="DummyFillerSpace" value=" " />
    > </appSettings>
    > When I try
    > <appSettings>
    > <add key="DummyFillerSpace" value="&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" />
    > </appSettings>
    > It fails. Here are the error messsage details:
    > System.Configuration.ConfigurationException: Reference to undeclared
    > parameter entity, 'nbsp'. (c:\inetpub\wwwroot\POWERWeb\web.config) --->
    > System.Xml.XmlException: Reference to undeclared parameter entity, 'nbsp'.
    > at System.Xml.XmlLoader.ExpandEntityReference(XmlEnti tyReference eref) at
    > System.Xml.XmlEntityReference.SetParent(XmlNode node) at
    > System.Xml.XmlNode.AppendChild(XmlNode newChild) at
    > System.Xml.XmlLoader.LoadAttributeChildren(XmlNode parent) at
    > System.Xml.XmlLoader.LoadAttributeNode() at
    > System.Xml.XmlLoader.LoadCurrentNode() at
    > System.Xml.XmlLoader.LoadElementNode() at
    > System.Xml.XmlLoader.LoadCurrentNode() at
    > System.Xml.XmlLoader.LoadCurrentNode() at
    > System.Xml.XmlLoader.LoadChildren(XmlNode parent) at
    > System.Xml.XmlLoader.LoadElementNode() at
    > System.Xml.XmlLoader.LoadCurrentNode() at
    > System.Xml.XmlLoader.LoadDocSequence(XmlDocument parentDoc) at
    > System.Xml.XmlLoader.Load(XmlDocument doc, XmlReader reader, Boolean
    > preserveWhitespace) at System.Xml.XmlDocument.Load(XmlReader reader) at
    > System.Configuration.ConfigXmlDocument.LoadSingleE lement(String filename,
    > XmlTextReader sourceReader) at
    >
    System.Web.Configuration.HttpConfigurationRecord.E valuateRecursive(IConfigur
    > ationSectionHandler factory, Object config, String[] keys, Int32 iKey,
    > XmlUtil xml) at
    > System.Web.Configuration.HttpConfigurationRecord.E valuate(String
    configKey,
    > SectionRecord section) --- End of inner exception stack trace --- at
    > System.Web.Configuration.HttpConfigurationRecord.E valuate(String
    configKey,
    > SectionRecord section) at
    > System.Web.Configuration.HttpConfigurationRecord.G etConfig(String
    configKey,
    > Boolean cacheResult) at
    > System.Web.Configuration.HttpConfigurationRecord.G etConfig(String
    configKey,
    > Boolean cacheResult) at System.Web.HttpContext.GetConfig(String name) at
    >
    System.Web.Configuration.HttpConfigurationSystemBa se.System.Configuration.IC
    > onfigurationSystem.GetConfig(String configKey) at
    > System.Configuration.ConfigurationSettings.GetConf ig(String sectionName)
    at
    > System.Configuration.ConfigurationSettings.get_App Settings() at
    > POWERWeb._Default.cmdLogin_Click(Object sender, EventArgs e) in
    > C:\Inetpub\wwwroot\POWERWeb\Login.aspx.vb:line 66
    >
    > "Mark MacRae" <nospam@nospam.com> wrote in message
    > news:urGMfTRXDHA.2576@TK2MSFTNGP09.phx.gbl...
    > > have you tried the HTML space character?
    > > "&nbsp;&nbsp;&nbsp;&nbsp"
    > >
    > > "VB Programmer" <growNO-SPAM@go-intech.com> wrote in message
    > > news:uH8OGMRXDHA.536@TK2MSFTNGP10.phx.gbl...
    > > > I have a ddl that is based on data from a datareader. Between column 0
    > and
    > > > column 1 I wanted to pad it with 15 spaces.
    > > >
    > > > Problem is it keeps only putting 1 space in between the columns! Any
    > > ideas?
    > > >
    > > > Here's a snippet...
    > > > drReader = cmdSqlCmd.ExecuteReader
    > > >
    > > > ' loop through reader and populate offices
    > > > Do While drReader.Read()
    > > > ddlOffice.Items.Add(drReader.GetString(0) & "
    "
    > &
    > > _
    > > > drReader.GetInt32(1))
    > > > Loop
    > > >
    > > >
    > >
    > >
    >
    >

    John Timney \(Microsoft MVP\) Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

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 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139