我在DELETE按钮列编码如下
private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName=="Delete")
{
dbutil dtl=new dbutil();
                this.DataGrid1.DataKeyField="itemid";
string itemid=this.DataGrid1.DataKeys[e.Item.ItemIndex].ToString();
this.Label1.Text=itemid;
SqlCommand cmd2=new SqlCommand();
cmd2.Connection=new SqlConnection(dtl.constr());
string sqlstr2="delete from lineitem where orderid="+Page.Session["orderid"]+" AND itemid="+itemid+"";
cmd2.CommandText=sqlstr2;
cmd2.CommandType=CommandType.Text;
cmd2.Connection.Open();
cmd2.ExecuteNonQuery();
cmd2.Connection.Close();
SqlCommand cmd4=new SqlCommand();
cmd4.Connection=new SqlConnection(dtl.constr());
string sqlstr4="select price,quantity,item.itemid from lineitem ,item where orderid="+Page.Session["orderid"]+"AND item.itemid=lineitem.itemid";
cmd4.CommandText=sqlstr4;
cmd4.CommandType=CommandType.Text;
SqlDataAdapter da4=new SqlDataAdapter(cmd4);
DataSet ds4=new DataSet();
da4.Fill(ds4);
this.DataGrid1.DataSource=ds4.Tables[0];
                
this.DataGrid1.DataBind();
}
运行时显示错误,是E.ITEM.ITEMIDEX超出了索引范围,请高手们帮忙回答一下