惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

F
Fortinet All Blogs
Attack and Defense Labs
Attack and Defense Labs
V2EX - 技术
V2EX - 技术
O
OpenAI News
S
Secure Thoughts
H
Heimdal Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
Schneier on Security
Schneier on Security
H
Hacker News: Front Page
S
Security Affairs
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Vercel News
Vercel News
Microsoft Security Blog
Microsoft Security Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
P
Proofpoint News Feed
The Register - Security
The Register - Security
GbyAI
GbyAI
Cloudbric
Cloudbric
MongoDB | Blog
MongoDB | Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
K
Kaspersky official blog
Forbes - Security
Forbes - Security
Y
Y Combinator Blog
C
CXSECURITY Database RSS Feed - CXSecurity.com
Scott Helme
Scott Helme
Hacker News - Newest:
Hacker News - Newest: "LLM"
The Cloudflare Blog
Recorded Future
Recorded Future
人人都是产品经理
人人都是产品经理
Cyberwarzone
Cyberwarzone
C
CERT Recently Published Vulnerability Notes
Webroot Blog
Webroot Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
L
LangChain Blog
T
Tor Project blog
Microsoft Azure Blog
Microsoft Azure Blog
博客园_首页
Hacker News: Ask HN
Hacker News: Ask HN
Blog — PlanetScale
Blog — PlanetScale
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
B
Blog RSS Feed
N
News and Events Feed by Topic
阮一峰的网络日志
阮一峰的网络日志
I
Intezer
V
V2EX
T
Tailwind CSS Blog
SecWiki News
SecWiki News
NISL@THU
NISL@THU
C
Check Point Blog

博客园 - 随风而去

easyui表格格线错位 从sp_executesql中返回table型数据及动态SQL语句的参数化查询 vb6转vb.net wss 备份与还原相关的站点 怎么用javascript进行拖拽 WSS3 顺序工作流之发布链接 域FRS复制策略失败后用ansiedit.msc用的着的几个值.恢复FRS对象或属性缺少 工作流一些链接 xp下自定义纸张 有用的几个系统过程 不错的CRM软件 wss3 Beta2 TR下载 终于完成第一个Wss3上WebPart(treeview 目录树形控件) 运行时选择界面上控件的方法 CODEDOM动态编译相关资料 asp.net 变量保存方法 利用IsPostBack检查网页是不是第一次进入(asp.net) 微软的设计思想:总感觉有点返祖现象,以前VB中很方便的功能,在C#中却要很复杂才能实现 treeview 用友u8之远程信道错误解决方法
gridview无数据行时显示表头的方法
随风而去 · 2007-03-22 · via 博客园 - 随风而去

//使用方法:
//在page_load事件中加入下列样式代码,其中grdPay为GridView. 必须设置grdPay的EmptyDataText属性不为空.
        if (this.IsPostBack == false)
        {
                grdPay.DataBind();
        }
        UGridView grd = new UGridView(grdPay);

//源程序
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public  class UGridView
{
    public  UGridView(GridView grd)
    {
        if (grd.EmptyDataText == "")
        {
            grd.EmptyDataText = "没有符合条件的数据";
        }
        grd.PreRender += new EventHandler(grd_PreRender);       
    }

    void grd_PreRender(object sender, EventArgs e)
    {
        DrawHeader(sender);
    }
    private void Grd_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowIndex == -1)
        {
            DrawHeader(sender);
        }
    }
    private void DrawHeader(object sender)
    {
        GridView grd = (GridView)sender;
        if (grd.Rows.Count > 0) return; //有数据,不要处理
        if (grd.DataSource != null)
        {
            if (((DataTable)grd.DataSource).Rows.Count > 0)
            {
                return;
            }
        }
        GridViewRow row = new GridViewRow(-1, -1,DataControlRowType.EmptyDataRow,DataControlRowState.Normal);
        foreach (DataControlField field in grd.Columns)
        {
            TableCell cell = new TableCell();
            cell.Text = field.HeaderText;
            cell.Width = field.HeaderStyle.Width;
            cell.Height = field.HeaderStyle.Height;
            cell.ForeColor = field.HeaderStyle.ForeColor;
            cell.Font.Size = field.HeaderStyle.Font.Size;
            cell.Font.Bold = field.HeaderStyle.Font.Bold;
            cell.Font.Name = field.HeaderStyle.Font.Name;
            cell.Font.Strikeout = field.HeaderStyle.Font.Strikeout;
            cell.Font.Underline = field.HeaderStyle.Font.Underline;
            cell.BackColor = field.HeaderStyle.BackColor;
            cell.VerticalAlign = field.HeaderStyle.VerticalAlign;
            cell.HorizontalAlign = field.HeaderStyle.HorizontalAlign;
            cell.CssClass = field.HeaderStyle.CssClass;
            cell.BorderColor = field.HeaderStyle.BorderColor;
            cell.BorderStyle = field.HeaderStyle.BorderStyle;
            cell.BorderWidth = field.HeaderStyle.BorderWidth;
            row.Cells.Add(cell);               
        }    
      
        TableItemStyle headStyle = grd.HeaderStyle;
        TableItemStyle emptyStyle = grd.EmptyDataRowStyle;
        emptyStyle.Width = headStyle.Width;
        emptyStyle.Height = headStyle.Height;
        emptyStyle.ForeColor = headStyle.ForeColor;
        emptyStyle.Font.Size = headStyle.Font.Size;
        emptyStyle.Font.Bold = headStyle.Font.Bold;
        emptyStyle.Font.Name = headStyle.Font.Name;
        emptyStyle.Font.Strikeout = headStyle.Font.Strikeout;
        emptyStyle.Font.Underline = headStyle.Font.Underline;
        emptyStyle.BackColor = headStyle.BackColor;
        emptyStyle.VerticalAlign = headStyle.VerticalAlign;
        emptyStyle.HorizontalAlign = headStyle.HorizontalAlign;
        emptyStyle.CssClass = headStyle.CssClass;
        emptyStyle.BorderColor = headStyle.BorderColor;
        emptyStyle.BorderStyle = headStyle.BorderStyle;
        emptyStyle.BorderWidth = headStyle.BorderWidth;
        if (grd.Controls.Count == 0)
        {
            grd.Page.Response.Write("<script language='javascript'>alert('必须在初始化表格类之前执行DataBind方法并设置EmptyDataText属性不为空!');</script>");
        }
        else
        {
            grd.Controls[0].Controls.Clear(); //删除没数据时的提示
            grd.Controls[0].Controls.AddAt(0, row);
        }          

    }

}