从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);
}