如何查找GridView的EmptyDataTemplate中的控件

网上看了很多用Controls[0].Controls[0]的方法,也很有道理,不过在有数据的情况写可能出出现Null异常,

这时你可以试试下面的方法,我感觉非常好用。

protected void GridViewSearchResult_RowCreated(object sender, GridViewRowEventArgs e)
    {
        
if (e.Row.RowType == DataControlRowType.EmptyDataRow)
        {
            ((Label)(e.Row.FindControl(
"LabelKeyword"))).Text = Request["keyword"];
        }
    }
posted on 2009-04-18 00:49  熵星尘  阅读(997)  评论(0编辑  收藏  举报