当前位置:编程学习 > asp >>

DataGrid多层表头设计

  <asp:datagrid id="UserDg" OnItemCreated="DataGrid1_ItemCreated"

        Public Sub DataGrid1_ItemCreated(ByVal sender As Object, ByVal e As

System.Web.UI.WebControls.DataGridItemEventArgs)
        If e.Item.ItemType = ListItemType.Header Then
            Dim tcl As TableCellCollection = e.Item.Cells
            tcl.Clear()
            tcl.Add(New TableHeaderCell)
            tcl(0).RowSpan = 2
            tcl(0).Text = "个人编码"

            tcl.Add(New TableHeaderCell)
            tcl(1).RowSpan = 2
            tcl(1).Text = "性别"

            tcl.Add(New TableHeaderCell)
            tcl(2).RowSpan = 2
            tcl(2).Text = "姓名"

            tcl.Add(New TableHeaderCell)
            tcl(3).RowSpan = 2
            tcl(3).Text = "服务<br>次数"

            tcl.Add(New TableHeaderCell)
            tcl(4).RowSpan = 2
            tcl(4).Text = "用户<br>修改"

            tcl.Add(New TableHeaderCell)
            tcl(5).RowSpan = 2
            tcl(5).Text = "健康<br>清单"

            tcl.Add(New TableHeaderCell)
            tcl(6).ColumnSpan = 4
            tcl(6).Text = "个人疾病危险性评价</td><td colspan=1 rowspan=2 align=center

valign=middle bgcolor=#0082C6><font color=#ffffff>管理<br>处方</font></td><td

rowspan=2 align=center valign=middle bgcolor=#0082C6><font color=#ffffff>汇总<br>报告

</font></td><td rowspan=2 align=center valign=middle bgcolor=#0082C6><font

color=#ffffff>重点<br>提示</font></td></tr><tr><td bgcolor=#848284 align=center

valign=middle><font color=#ffffff>糖尿病</font></td><td bgcolor=#848284 align=center

valign=middle><font color=#ffffff>中风</font></td><td bgcolor=#848284 align=center

valign=middle><font color=#ffffff>冠心病</font> </td><td bgcolor=#848284

align=center valign=middle><font color=#ffffff>肺癌</font>"
          
        End If
    End Sub DataGrid1_ItemCreated
             关键的部分是
            tcl.Add(New TableHeaderCell)
            tcl(6).ColumnSpan = 4
            tcl(6).Text = "个人疾病危险性评价</td><td colspan=1 rowspan=2 align=center

valign=middle bgcolor=#0082C6><font color=#ffffff>管理<br>处方</font></td><td

rowspan=2 align=center valign=middle bgcolor=#0082C6><font color=#ffffff>汇总<br>报告

</font></td><td rowspan=2 align=center valign=middle bgcolor=#0082C6><font

color=#ffffff>重点<br>提示</font></td></tr><tr><td bgcolor=#848284 align=center

valign=middle><font color=#ffffff>糖尿病</font></td><td bgcolor=#848284 align=center

valign=middle><font color=#ffffff>中风</font></td><td bgcolor=#848284 align=center

valign=middle><font color=#ffffff>冠心病</font> </td><td bgcolor=#848284

align=center valign=middle><font color=#ffffff>肺癌</font>"
            
现在Table中设计出来结构,然后将双引号变成单引号,在添加到TableHeaderCell.text中就可以了。多复杂的都可以实现。


补充:Web开发 , ASP.Net ,
CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,