private void dgTeam_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType==ListItemType.AlternatingItem || e.Item.ItemType==ListItemType.Item)
{
LinkButton btnLinkDelete=(LinkButton)e.Item.Cells[4].Controls[0];
if(btnLinkDelete!=null)
{
Label labTeamName=(Label)e.Item.FindControl("LabName");
string strScript="return ConfirmDelete('"+labTeamName.Text.ToString()+"');";
btnLinkDelete.Attributes.Add("onclick",strScript);
}
}
}
html部分我就不写了,应该没什么问题了吧!