zoukankan      html  css  js  c++  java
  • GridView的列的数据分行显示

    今天,在将数据绑定到GridView时,发现其中一个列的数据特别的长,占去了页面大部分的宽度,如下图,

    怎样使这列的数据像旁边的两列一样显示呢?

    首先,设置当前列的Item_style中的Wrap 属性为True。一般,这样就可以了。如果数据格式是像上图显示的一样,那就麻烦了。 因为,AutoWrap 只会在遇到空格才会换行。

    在我的项目中,因为这行数据是在绑定后插入的,所以解决起来比较容易。

    Protected Sub FillTest()
    Dim cs As String = ConfigurationManager.ConnectionStrings("TestConnectionString").ConnectionString.ToString
    Dim cn As New SqlClient.SqlConnection(cs)
    Dim cmdText As String = "SELECT qr.character1,qr.character2 FROM table1 qr, table2 qp Where qr.plan_id = qp.plan_id"
    Dim cmd As New SqlClient.SqlCommand(cmdText, cn)
    Dim charSeparators() As Char = {";"c}
    Dim da As New SqlClient.SqlDataAdapter(cmd)
    cmd.CommandTimeout
    = 600
    Dim hstblSalesOffice As New Hashtable

    Dim salesOffices, hshKey, hshValue, LBPPersonName As String
    Dim ds As New Data.DataSet
    Dim drChar As DataRow
    da.Fill(ds)
    For Each drChar In ds.Tables(0).Rows
    LBPPersonName
    = drChar("character1")
    salesOffices
    = drChar("character2")
    For Each hshKey In salesOffices.Split(charSeparators, StringSplitOptions.None)
    If hstblSalesOffice.ContainsKey(hshKey) Then
    If (txtCSPerson.Text.Trim() = String.Empty) Then
    hshValue
    = hstblSalesOffice.Item(hshKey)
    'Column wrap will work only when there are some spaces between strings
    hshValue = hshValue & " / " & LBPPersonName
    hstblSalesOffice.Item(hshKey)
    = hshValue
    Else
    hshValue
    = txtCSPerson.Text.ToString
    hstblSalesOffice.Item(hshKey)
    = hshValue
    End If
    Else
    hstblSalesOffice.Add(hshKey, LBPPersonName)
    End If
    Next
    Next
    Session(
    "CSPerson") = hstblSalesOffice
    ds.Dispose() : da.Dispose() : cmd.Dispose() : cn.Dispose()
    End Sub
  • 相关阅读:
    i++与++i
    acm语录
    c# SQL2000 access 远程连接操作
    C# 四舍五入函数
    WINDOWS 2003 远程桌面记录登陆IP
    jquery 资源
    php google baidu 分页
    Solutions to place plus or minus signs to a nonzero digits sequence 123456789 so that result of thus described arithmetic opera
    VB获取网页下文字的链接地址
    php cache 缓存方法类一
  • 原文地址:https://www.cnblogs.com/Dannier/p/1978609.html
Copyright © 2011-2022 走看看