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 操作ie 登陆土豆再退出
    python之sqlite3使用详解(转)
    python 获取当前目录下文件(转)
    python中使用time模块计算代码执行效率的精度测试(转)
    pythonhttplib模块使用(转)
    python技巧31[python中使用enum](转)
    python怎样压缩和解压缩ZIP文件(转)
    httplib2python下的http请求终结者(转)
    Python:使用ctypes库调用外部DLL(转)
    整理了下控制ie的代码(转)
  • 原文地址:https://www.cnblogs.com/SNS/p/1226478.html
Copyright © 2011-2022 走看看