设置GridView控件表头背景图片
Admin | 2007-11-10 11:25:49 | 被阅次数 | 8109
代码如下,请自行修改并应用
private void GridView1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Header)
{
e.Item.Attributes.Add("style", "background-image:url('background.gif')");
}
}
GridView:
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Attributes.Add("style", "background-image:url('background.gif')");
}
}