您的位置:首页 > 其它

add a confirm dialogbox to the editItem of the datagrid

2005-09-16 09:20 639 查看
//first add a delegate in private void InitializeComponent()
this.DataGrid1.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.DataGrid1_ItemCreated);
private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
ListItemType lit = e.Item.ItemType;
if (lit == ListItemType.Item || lit == ListItemType.AlternatingItem)
{
CustomizeItem(e);
}
}
private void CustomizeItem(DataGridItemEventArgs e)
{
WebControl wc;
int i = e.Item.Cells.Count -1;
wc = ((WebControl) e.Item.Cells[i]);
wc.Height = 25;//set the item's style
wc.Width = 25;
String js = "return confirm("Delete it?");";
wc.Attributes.Add("onclick", js);
// wc.ToolTip = e.Item.Cells[0].Text.Trim() + "...";
wc.ToolTip += "Delete this row";
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐