http://dotnet.aspx.cc/Exam/DataGridCheckBox/DataGridCheckBox.aspxhttp://dotnet.aspx.cc/ShowDetail.aspx?id=FF130C7F-3650-4DA6-8943-8AA4AF3E3459执行删除操作即可
解决方案 »
- ie 头和ie 尾截图
- 通用存储过程参数传递问题
- Jquery ajax 返回值在Label上不显示?求教
- 如何让gridview模板中的RadioButton中能选取一项,像RadioButtonList
- 讨论,大家开发一个常见网站时都是怎么做的?
- 求救啊。学生题,请问一个ASP.net的聊天室怎么搞,求算发,
- 求助:C#编写的网站,为什么用VS编辑源代码运行后还是原来的效果
- 现在网上的短网址算法碰撞机率太大,有没变长的方案?这样能杜绝碰撞不?
- 字符串截取问题!
- 巨急,巨难! HELP : SOS : 一个ASP的表单参数传递code 转为 C# code !!!
- CSDN社区左侧的导航栏是如何实现的?
- 还有一个数据库操作问题,我执行INSERT语句时,语句都没有问题,怎么提示“必须要一个可更新的操作”
附:
我刚写的实现删除的代码
private void Button6_Click(object sender, System.EventArgs e)
{
string ID=null;
foreach(DataGridItem item in DataGrid1.Items)
{ CheckBox txtID = (CheckBox)item.FindControl("chkDelServer"); if (txtID.Checked == true)
{
ID=txtID.Text;
string SQL = "DELETE FROM News_News WHERE News_ID="+ ID +"";
string connstr=System.Configuration.ConfigurationSettings.AppSettings["strConnection"].ToString();
SqlConnection conn=new SqlConnection(connstr);
SqlCommand comm=new SqlCommand(SQL,conn); conn.Open();
comm.ExecuteNonQuery();
conn.Close();
}
} Response.Redirect("xxxx.aspx");//返回}
{
string dgIDs = "";
bool BxsChkd = false;
foreach (DataGridItem i in MyDataGrid.Items)
{
CheckBox deleteChkBxItem = (CheckBox) i.FindControl ("DeleteThis");
if (deleteChkBxItem.Checked)
{
BxsChkd = true;
dgIDs += ((Label) i.FindControl ("StoreID")).Text.ToString() + ",";
}
}
string deleteSQL = "DELETE from Stores WHERE stor_id IN (" + dgIDs.Substring (0, dgIDs.LastIndexOf (",")) + ")"; if (BxsChkd == true)
{
try
{
//SqlHelper.ExecuteNonQuery (objConnect, CommandType.Text, deleteSQL);//根据delete from youtable where id in()来执行批删除
OutputMsg.InnerHtml+="删除"+dgIDs.ToString().Trim()+"成功";
OutputMsg.Style["color"] = "#3366cc";
}
catch (SqlException err)
{
OutputMsg.InnerHtml += err.Message.ToString();
OutputMsg.Style["color"] = "#6699cc";
}
BindData();
}
http://www.cnblogs.com/smilnet/archive/2004/07/17/25150.aspx