string temp = GridView1.DataKeys[e.RowIndex].Value.ToString();
DataTable dt = (DataTable)ViewState["wareadd"];
DataRow[] dr = dt.Select("iWareID='" + temp + "'");
foreach (DataRow eachrow in dr)
{
dt.Rows.Remove(eachrow);
}
GridView1.DataSource = dt;
ViewState["wareadd"] = dt;
GridView1.DataBind();
DataTable dt = (DataTable)ViewState["wareadd"];
DataRow[] dr = dt.Select("iWareID='" + temp + "'");
foreach (DataRow eachrow in dr)
{
dt.Rows.Remove(eachrow);
}
GridView1.DataSource = dt;
ViewState["wareadd"] = dt;
GridView1.DataBind();
![](https://i-blog.csdnimg.cn/blog_migrate/2f60c0bc47d4178ac5e2b807936153ff.gif)