OnItemDataBound事件是在项被绑定数据后触发的事件
例如在gridveiw 或ListView控件中添加这个事件OnItemDataBound="lvPhoto_ItemDataBound"
在后台就可以使用此事件
protected void lvPhoto_ItemDataBound(object sender, ListViewItemEventArgs e)
{
查找控件linkbutton 删除提示
LinkButton lb = (LinkButton)e.Item.FindControl("del");
if (lb != null)
{
lb.Attributes.Add("onclick", "return confirm('确定要删除去吗!')");
}
或者
ImageButton ima = (ImageButton)e.Row.FindControl("del");
if (ima != null)
{
ima.Attributes.Add("onclick", "return confirm('确定要删除吗!')");
}
等等。。。。
}