I have a DropDownList populated from a LINQ query. As per the design requirements of this project, I need to append 4 ‘ ‘ to the DDL’s ListItem.Text.
It works when I add the ListItems manually like so:
<asp:ListItem Value='NULL'>&nsbp;&nsbp;&nsbp;&nsbp;Select One</asp:ListItem>
but not when I DataBind() and use:
DataTextFormatString = '&nsbp;&nsbp;&nsbp;&nsbp;{0}';
Any help is appreciated.
AND: Before someone says something about the HTML code, I had to call it a ‘&nsbp;’ since it wouldn’t allow me to use Non-Breaking Space char code.
Thanks!
The only thing that I can think to do is sub-class the dropdownlist control and override the render method and see if you can’t circumvent the trimming that the base dropdownlist control is doing on its items collection.
If sub-classing is too much work, then use some client side Javascript code to update those items upon page load. This would be a snap with JQuery. I hope that helps.