html代码如下:
然后把删除代码写在rowdeleting事件中:
<asp:templatefield headertext="删除">
<itemtemplate>
<asp:linkbutton id="linkbutton1" runat="server" commandname="delete" onclientclick="return confirm('确认要删除吗?');">删除</asp:linkbutton>
</itemtemplate>
</asp:templatefield>
然后把删除代码写在rowdeleting事件中:
protected void gridview1_rowdeleting(object sender, gridviewdeleteeventargs e)
{
int j = convert.toint32(gridview1.datakeys[e.rowindex].value);
addb.deleteadtype(j);
gridview1.datasource = addb.getadtype().tables[0];
gridview1.databind();
}