.aspx:
<asp:TemplateColumn>
<HeaderStyle Wrap="False" HorizontalAlign="Center"></HeaderStyle>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" AutoPostBack="True" Checked="False" TextAlign="Right" Text="Delete" Runat="server"></asp:CheckBox>
</ItemTemplate>
</asp:TemplateColumn>
.cs:
private void Delete_Click(object sender, System.EventArgs e) //删除按钮事件
{
for(int i=0;i<this.DataGrid1.Items.Count;i++)
{
if(((CheckBox)DataGrid1.Items[i].Cells[1].FindControl("CheckBox1")).Checked == true)
{
string id = DataGrid1.Items[i].Cells[1].Text.ToString().Trim();
myConnection.Open();
string strd="delete from TRANSCEIVERLIST where TRANSCEIVER='"+id+"'";
FTRSOWEB.Class.database f5=new FTRSOWEB.Class.database();//调用类文件中的类
f5.Execute(strd);
myConnection.Close();
}
}
data();//刷新数据
}
提示按钮:
Delete.Attributes.Add("onclick", "return confirm('你是否确定删除选中的记录?');");//放在Page_Load模块中