Displaying Multiple columns in a HTML ListBox control in ASP. NET

Source: Internet
Author: User

Ref:

Http://forums.aspfree.com/net-development-11/displaying-multiple-columns-in-a-html-listbos-control-in-asp-19062.html

 

ListBox column spacing Solution

Finally !!! I know so far people have had this problem. But finally I solved it with your basic mono spacing font type.

As we all know the Asp.net ListBox has a problem with truncating all added spaces. so you can't create columns with in your ListBox. but all your need to do is use the command Sever. htmldecode (string) that will send whatever is in inside it directly to HTML. the problem was there ListBox wocould change the & to amp; so the spaces wouldn't come out. but with this command the & will not get changed. the space html ascii to use wocould either be or & nbsp; just put either inside your server. htmldecode () and your set .. walla spacing .......

Here is an example I'm using and SQL Server to get data but you should get the idea.

{
Dim dreader as sqlclient. sqldatareader
Dim sqlcmd as sqlclient. sqlcommand = new sqlclient. sqlcommand ("select tm_tax_code, tm_tax_description from [tax-master] order by tm_tax_code", conn1)
Sqlcmd. Connection. open ()
Dreader = sqlcmd. executereader

Dim taxcode as string
Dim taxnum as integer = 8
Dim tempspace as string
Dim CT as integer
Ct = 0

Do While dreader. Read
Taxcode = trim (dreader ("tm_tax_code "))
Taxnum-= Len (taxcode)
For Ct = 0 to taxnum
Tempspace = tempspace &""
Next

Lsttaxmaster. Items. Add (TRIM (dreader ("tm_tax_code") & server. htmldecode (tempspace) & dreader ("tm_tax_description "))
Tempspace = ""
Taxnum = 8
Loop

Sqlcmd. Connection. Close ()
}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.