zoukankan      html  css  js  c++  java
  • 空数据时显示GridView及设置网格线式样

        Private Sub GridView1_DataBinding(ByVal sender As ObjectByVal e As System.EventArgs) Handles GridView1.DataBinding
            
    '空数据时添加空行
            Dim dt As Object = sender.DataSource
            
    If dt.Rows.Count = 0 Then
                dt.Rows.Add(dt.NewRow())
            
    End If
        
    End Sub


        
    Private Sub GridView1_RowDataBound(ByVal sender As ObjectByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
            
    '隐藏添加的空行
            If e.Row.RowType <> DataControlRowType.Header AndAlso e.Row.RowType <> DataControlRowType.Footer AndAlso e.Row.RowIndex = 0 Then
                
    If String.IsNullOrEmpty(sender.DataKeys(e.Row.RowIndex).Value.ToString()) Then
                    e.Row.Visible 
    = False
                
    End If
            
    End If

            
    '设置网格线式样为边框式样
            For Each tc As TableCell In e.Row.Cells
                tc.ControlStyle.BorderStyle 
    = sender.BorderStyle
                tc.ControlStyle.BorderWidth 
    = sender.BorderWidth
            
    Next
        
    End Sub


        
    Private Sub GridView1_PreRender(ByVal sender As ObjectByVal e As System.EventArgs) Handles GridView1.PreRender
            
    '设置网格线颜色为边框颜色
            sender.Attributes("BorderColor"= System.Drawing.ColorTranslator.ToHtml(sender.BorderColor)
        
    End Sub
  • 相关阅读:
    Python基础教程:多线程运行带多个参数的函数
    Python基础教程:list相关操作
    python字典教程:setdefault方法和get方法
    Python 异常处理集合
    python基础教程:5个带key的python内置函数
    python操作Excel的5种方式
    Python3压缩和解压缩实现
    jenkins 分布式配置主从节点
    CentOS7 free字段含义
    nginx配置https
  • 原文地址:https://www.cnblogs.com/SNS/p/1226478.html
Copyright © 2011-2022 走看看