微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

Displaying multiple columns in a HTML Listbox Control in ASP.Net

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 many 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 would 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 would either be   or   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()
}

 

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐