
2009年4月18日
如何查找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 @ 2009-04-18 00:49 奇拉 阅读(813) 评论(0)
编辑