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
  • 相关阅读:
    day03--变量与基本数据类型
    day02--编程语言的分类与Python开发环境的搭建
    day01--编程与计算机组成原理
    基本数据类型操作
    python格式化字符串
    Python垃圾回收机制
    day04作业
    day03作业
    Pycharm2018安装与激活
    Python入门-python浅谈
  • 原文地址:https://www.cnblogs.com/Dannier/p/1978609.html
Copyright © 2011-2022 走看看