类型:转载 责任编辑:asp 日期:2007/03/01
搞不定呀
<asp:datagrid id="mygrid" runat="server" onitemcreated="itemcreated" onitemcommand="griddel" onupdatecommand="gridupdate" width="468px" ondeletecommand="griddel" bordercolor="black" autogeneratecolumns="false" allowpaging="true" onpageindexchanged="pagechange" oneditcommand="gridedit" oncancelcommand="gridcancle" >
<alternatingitemstyle backcolor="#ffff66"></alternatingitemstyle>
<headerstyle bordercolor="black" backcolor="#339966"></headerstyle>
<columns>
<asp:boundcolumn datafield="id" headertext="id"></asp:boundcolumn>
<asp:boundcolumn datafield="name" headertext="name"></asp:boundcolumn>
<asp:editcommandcolumn buttontype="linkbutton" updatetext="更新" canceltext="取消" edittext="编辑"></asp:editcommandcolumn>
<asp:templatecolumn>
<itemtemplate>
<asp:button id="del" runat="server" commandname="delname" causesvalidation="false" text="删除"></asp:button>
</itemtemplate>
</asp:templatecolumn>
</columns>
</asp:datagrid>
-----------------------
public void itemcreated(object sender,datagriditemeventargs e){
webcontrol objbutton;
switch(e.item.itemtype)
{
case listitemtype.item:
objbutton=(webcontrol)e.item.findcontrol("del");
objbutton.attributes["onclick"]="return confirm("+e.item.itemtype+");";
break;
case listitemtype.alternatingitem:
objbutton=(webcontrol)e.item.findcontrol("del");
objbutton.attributes.add("onclick","return confirm("+e.item.itemtype+");");
break;
}
}
推荐阅读