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

推荐订阅源

WordPress大学
WordPress大学
Microsoft Security Blog
Microsoft Security Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
V
Visual Studio Blog
宝玉的分享
宝玉的分享
IT之家
IT之家
人人都是产品经理
人人都是产品经理
T
The Blog of Author Tim Ferriss
I
InfoQ
B
Blog RSS Feed
T
Threatpost
博客园_首页
M
MIT News - Artificial intelligence
Spread Privacy
Spread Privacy
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Know Your Adversary
Know Your Adversary
U
Unit 42
Engineering at Meta
Engineering at Meta
C
Cyber Attacks, Cyber Crime and Cyber Security
月光博客
月光博客
Scott Helme
Scott Helme
T
Tor Project blog
有赞技术团队
有赞技术团队
AWS News Blog
AWS News Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Last Week in AI
Last Week in AI
S
Schneier on Security
Vercel News
Vercel News
博客园 - Franky
C
Cybersecurity and Infrastructure Security Agency CISA
L
LINUX DO - 热门话题
NISL@THU
NISL@THU
L
LangChain Blog
爱范儿
爱范儿
Google DeepMind News
Google DeepMind News
The GitHub Blog
The GitHub Blog
雷峰网
雷峰网
Latest news
Latest news
C
CXSECURITY Database RSS Feed - CXSecurity.com
Hugging Face - Blog
Hugging Face - Blog
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
G
GRAHAM CLULEY
S
Security Affairs
A
About on SuperTechFans
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
大猫的无限游戏
大猫的无限游戏
W
WeLiveSecurity
Cisco Talos Blog
Cisco Talos 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);
        }          

    }

}