Displaying multiple columns in a HTML Listbox Control in ASP.Net
  TnD0WQEygW8e 2023年11月09日 62 0

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()

}


【版权声明】本文内容来自摩杜云社区用户原创、第三方投稿、转载,内容版权归原作者所有。本网站的目的在于传递更多信息,不拥有版权,亦不承担相应法律责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@moduyun.com

  1. 分享:
最后一次编辑于 2023年11月09日 0

暂无评论

推荐阅读
  biE3E3UjTjeg   2024年01月22日   50   0   0 SQLSQL
  anLrwkgbyYZS   2023年12月30日   52   0   0 ciciideideMaxMax