我正在尝试使用CommandName删除一行,但无法将其删除。请告诉我如何操作。
gridview与内部联接查询绑定,那么如何删除行?
我试过这个:
protected void Gridview1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "removeRow")
{
int picID = Convert.ToInt32(e.CommandArgument);
GridView1.DeleteRow(picID);
GridView1.DataBind();
}
}
在gridview查询中,我添加了这个:
str = "select * from Products INNER JOIN orders on Products.picID=orders.productID";
SqlCommand cmd = new SqlCommand(str, con);
con.Open();