asp.net问题:Gridview中选中checkbox的多行如何删除?(用linqdatasource写)
protectedvoidbtnDelete_Click(objectsender,EventArgse){DataClassesDataContextdb=newDat...
protected void btnDelete_Click(object sender, EventArgs e)
{
DataClassesDataContext db = new DataClassesDataContext();
foreach(GridViewRow gvRow in GridView1.Rows)
{
CheckBox chkItem = (CheckBox)gvRow.FindControl("chkItem");
if(chkItem.Checked)
{
var re = from r in db.OrderItem
where r //这里不会写
select r;
db.OrderItem.DeleteAllOnSubmit(re);
db.SubmitChanges();
}
}
GridView1.DataBind();
}
buttton要求在gridview外面 展开
{
DataClassesDataContext db = new DataClassesDataContext();
foreach(GridViewRow gvRow in GridView1.Rows)
{
CheckBox chkItem = (CheckBox)gvRow.FindControl("chkItem");
if(chkItem.Checked)
{
var re = from r in db.OrderItem
where r //这里不会写
select r;
db.OrderItem.DeleteAllOnSubmit(re);
db.SubmitChanges();
}
}
GridView1.DataBind();
}
buttton要求在gridview外面 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询