How to render white space in HTML, Asp:DropDownLists, unbound, C# codebehind, bound to DataTable?

I am endeavoring to render leading spaces in a DropDownList (Ddl).
the Ddl is bound to a DataTable from my c# codebehind.
I am new to this, not familiar with all the syntax and the usage of all the available <tags>
I have read and tested "The browser is rendering spaces as one space" and believe this is my issue...

BTW I am rendering a up to 6 digit number followed by some text...
_____1 person full name
____10 different person name
___101 another person name
__1234 yet another

Please do not rely on my testing below, as my implementation could have made THE PROPER SOLUTION not work...
I have tried:
1) used leading "&nbsp;", " &nbsp;", "& nbsp;", "&nbsp; + " -" + "&nbsp; &nbsp; " + string and I reliably get the escape characters rendered perfectly!

2) <pre></pre>, besides messing up my webform it still renders one space or the &nbsp; in the control

3) several other formatting suggestions, however method I use to format they all create data in my table which I view with vs.  It does not matter how you format the resulting string in the table is what gets passed to the control

Thank You
Sam

code
                 
                ddlStd.Proc = "GetddlDivisionsProc"; // set proper sproc for data
               
               ddlDropDownList.DataSource = ddlStd.OutTable; //get the data table, (ddlStd gets the data from sqldb and
                concatenates columns then adds row by row to the table, resulting in a two row table 1 for "value" and the       other for "text")
               
                ddlDropDownList.DataValueField = "Value";
               
                ddlDropDownList.DataTextField = "Text";
               
                ddlDropDownList.DataBind();
SamCashAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SamCashAuthor Commented:
This solved my issue.  Must be after binding.

foreach (ListItem item in ddlUID.Items) //This enables the browser to not to reformat data changing multiple white space to one space, and from trimming spaces
            {
                item.Text = HttpUtility.HtmlDecode(item.Text);// render "&nbsp; " left padding
            }

Open in new window


Regards
Sam
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
HTML

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.