日期:2014-05-20  浏览次数:20426 次

大家帮帮忙DATAGRID
在DATAGRID里加了一个模板列里面有个删除按纽,怎么让删除数据的时候弹出确认框
//删除
if(e.CommandName== "Delete ")
{
DBConn   myDB=new   DBConn();
string   strsql= "delete   from   newswhere   id= "+e.Item.Cells[0].Text;
myDB.getExecuteNoQuery(strsql);
Response.Write( " <script> alert( '删除成功! ') </script> ");
myDB.Close();
DataGridNewBind();
}

------解决方案--------------------
Button.Attribute.Add( "onclick ", "return confirm( '您确定要删除吗? '); ");
------解决方案--------------------
html:
linkbutton中添加
onclick = "return confirm( '确认删除? '); "
就行了
------解决方案--------------------
Button.Attribute.Add( "onclick ", "return confirm( '您确定要删除吗? '); ");
需要写在ITEMBIND里面,用FINDCONTROL找到它
------解决方案--------------------
在page_load中写
ButtonID.Attribute.Add( "onclick ", "return confirm( '您确定要删除吗? '); ");