Repeater 里面加个绑定CheckBox 而后
单位 批量删除的时候 public static string GetString(Repeater ControlsID)
{
string StrDelete = "";
foreach (RepeaterItem i in ControlsID.Items)
{
if (((HtmlInputCheckBox)i.FindControl("CheckBoxSelect")).Checked)
{
StrDelete += ((HtmlInputCheckBox)i.FindControl("CheckBoxSelect")).Value + ",";
}
}
StrDelete = StrDelete.TrimEnd(',');
return StrDelete;
}
返回唯一标识 ,直接就可以删除了。
单位 批量删除的时候 public static string GetString(Repeater ControlsID)
{
string StrDelete = "";
foreach (RepeaterItem i in ControlsID.Items)
{
if (((HtmlInputCheckBox)i.FindControl("CheckBoxSelect")).Checked)
{
StrDelete += ((HtmlInputCheckBox)i.FindControl("CheckBoxSelect")).Value + ",";
}
}
StrDelete = StrDelete.TrimEnd(',');
return StrDelete;
}
返回唯一标识 ,直接就可以删除了。
解决方案 »
- 视频显示问题
- 请问一下workerRequest.GetPreloadedEntityBody(); 始终是null,该怎么解决。
- 使用JS动态添加table的行,这添加的行想要与数据绑定要怎么弄?
- vs2010和2008有没有大的区别
- 新手求教:关于查询页面及提交
- win2000Server系统,IIS中,当请求XML出现,弹出对话框:XML request error:Internal Server Error(500)怎样解决?
- 在dreamwear中如何在图片在加字呀
- 关于在ASP.NET中发送短消息的问题!!
- !!!!!!!!真的没有分了,问大家一个问题,如何实现左边是导航兰当点击的时候在右边的一个div层当中实现连接呢????
- System.NullReferenceException: 未将对象引用设置到对象的实例
- 如何用asp.net实现歌曲下载
- 数据是从数据库中读出,怎样获取下拉列表框中的ID
后台删除按钮事件里写
delete 表 where id in ("+Request.Form["ID"]+")
string ch = string.Empty;//存放选择的ID
string jch = string.Empty;//截取后的ID
foreach (RepeaterItem ri in rep1.Items)
{
CheckBox cb = ri.FindControl("chkb") as CheckBox;
HiddenField hid = ri.FindControl("hidd") as HiddenField;
if (cb.Checked == true)
{
count++;
ch += hid.Value.ToString() + ",";
jch = ch.Substring(0, ch.LastIndexOf(','));
}
}
if (count > 0)
{
//执行删除
}
if (count == 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('请选择数据行!');", true);
}
然后就是一个Delete语句了,使用In就可以
{
for (int i = 0; i < reapter.Items.Count; i++)
{
CheckBox cbx = reapter.Items[i].FindControl("chkDel") as CheckBox;
if (cbx.Checked)
{
string sql = "delete " + 表名 + " where id = " + long.Parse(cbx.ToolTip);
执行删除 }
}
}
记得给chkDel 的属性 ToolTip = '<%# Eval("id") %>'
string ch = string.Empty;//存放选择的ID
string jch = string.Empty;//截取后的ID
foreach (RepeaterItem ri in repeater.Items)
{
CheckBox cb = ri.FindControl("chkDel") as CheckBox;
HiddenField hid = ri.FindControl("hidhid") as HiddenField;
if (cb.Checked == true)
{
count++;
ch += hid.Value.ToString() + ",";
jch = ch.Substring(0, ch.LastIndexOf(','));
}
}
if (count > 0)
{
string sql = "delete from FD_Movie where [id] in (" + Request.Form["id"] + ")"; if (DbHelper.GetInstance().ExecuteSql(sql))
{
ShowSuccessMsg("成功", "listmovie.aspx");
}
else
{
ShowSuccessMsg("失败", "listmovie.aspx");
}
}
if (count == 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('请选择数据行!');", true);
}
}语法错误 (操作符丢失) 在查询表达式 '[id] in ()' 中。
调试的时候出现这个问题 到底是什么原因??????????
string ch = string.Empty;//存放选择的ID
string jch = string.Empty;//截取后的ID
foreach (RepeaterItem ri in repeater.Items)
{
CheckBox cb = ri.FindControl("chkDel") as CheckBox;
HiddenField hid = ri.FindControl("hidhid") as HiddenField;
if (cb.Checked == true)
{
count++;
ch += hid.Value.ToString() + ",";
jch = ch.Substring(0, ch.LastIndexOf(','));
}
}
if (count > 0)
{
string sql = "delete from FD_Movie where [id] in (" + Request.Form["id"] + ")"; if (DbHelper.GetInstance().ExecuteSql(sql))
{
ShowSuccessMsg("成功", "listmovie.aspx");
}
else
{
ShowSuccessMsg("失败", "listmovie.aspx");
}
}
if (count == 0)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "", "alert('请选择数据行!');", true);
}
} 语法错误 (操作符丢失) 在查询表达式 '[id] in ()' 中。
调试的时候出现这个问题 到底是什么原因??????????