日期:2014-05-16 浏览次数:20535 次
<div>
<asp:GridView ID="GV" runat="server" OnRowDeleting="GV_RowDeleting" >
<Columns>
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
</div>
var result = from r in lqDB.KC
where r.ID == 如何判断呢?
where r.ID > 0
select r;
lqDB.KC.DeleteAllOnSubmit(result);
lqDB.SubmitChanges();
protected void GridView1_OnRowDeleting(object sender, GridViewDeleteEventArgs e)
{
int id = Convert.ToInt32 ( GridView1.DataKeys[e.RowIndex].Value);//获得要删除行的id
var result = from r in lqDB.KC
where r.ID == id
where r.ID > 0
select r;
lqDB.KC.DeleteAllOnSubmit(result);
lqDB.SubmitChanges();
}