行删除事件在gridview中给出错误

时间:2016-01-12 12:39:26

标签: c# asp.net gridview

从gridview抛出错误中删除行 -

  

指定的参数超出了有效值的范围。

aspx代码

<asp:GridView runat="server" ID="gridviewEditProformaInvoice" OnRowEditing="gridviewEditProformaInvoice_RowEditing" AutoGenerateEditButton="true"  OnRowCancelingEdit="gridviewEditProformaInvoice_RowCancelingEdit" AutoGenerateDeleteButton="true" OnRowUpdating="gridviewEditProformaInvoice_RowUpdating" OnRowDeleting="gridviewEditProformaInvoice_RowDeleting" ></asp:GridView>

背后的代码

protected void gridviewEditProformaInvoice_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
     SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["abc"].ConnectionString);
     GridViewRow row = gridviewEditProformaInvoice.Rows[e.RowIndex];

     string uniqueid = (row.Cells[2].Controls[0] as TextBox).Text;
     SqlCommand cmd = new SqlCommand(@"delete from tbl_proformaDetails WHERE uniqueid ='" + uniqueid + "'", abc);
}

0 个答案:

没有答案