<ItemTemplate>
<input type='checkbox' name='checked' value='<%# DataBinder.Eval(Container.DataItem, "dj_id")%>'>
</ItemTemplate>
if (Request["checked"] != null)
{
string TempStr = Request["checked"].ToString();
string[] Strs = TempStr.Split(',');
foreach (string Str in Strs)
{
//Response.Write(Str);
SqlConnection connection = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["connstring"].ToString());
connection.Open();
string sql = "delete from tb_myfile where dj_id='" + Str + "'";
SqlCommand cmd = new SqlCommand(sql, connection);
cmd.ExecuteNonQuery();
connection.Close();
}
Response.Redirect("mymusicbox.aspx");
}
本文展示了一个使用ASP.NET从数据库中删除特定记录的示例代码。通过复选框选择要删除的项,并利用C#及SQL语句完成删除操作。涉及到数据库连接、SQL命令执行等关键技术。
2102

被折叠的 条评论
为什么被折叠?



