When i insert record into database from GridView below error is come
Input string was not in a correct format.
on below line
int inv_id = Convert.ToInt32((row.FindControl("Inv_ID") as Label).Text.Trim());
Means that last row, in which i display total, it does not have ID, insert query also try to read it then error occur, so how to prevent to go on last row where i display total.
protected void btn_Save_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in GVFood.Rows)
{
LoadRecordID();
int inv_id = Convert.ToInt32((row.FindControl("Inv_ID") as Label).Text.Trim());
TextBox txtRec_amt = row.FindControl("txtRec_amt") as TextBox;
int cus_id = Convert.ToInt32((row.FindControl("Customer_id") as Label).Text);
int item_wt = Convert.ToInt32((row.FindControl("item_Weight") as Label).Text);
// DropDownList ddl = row.FindControl("ddlStatus") as DropDownList;
if (!string.IsNullOrEmpty(txtRec_amt.Text) )
{
Insert(Convert.ToInt32(txtRec_amt.Text.Trim()), inv_id, cus_id, item_wt);
}
}
}