Hey there,
As stated in your comments above you are getting the docid as '0', which is the reason why insertion in table Approval is causing the Exception.
You are using the values from the Session in this statement, which does not seem right as its in a loop and you'll be inserting same values for all rows:
docc.approve(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["DocID"]), Convert.ToInt32(Session["ApproveID"]), Convert.ToString(Session["Login2"]));
Firstly, I would suggest you to use the
GridView DataKeys
for UserID and DOCID and DropDownList value from approval ID.
Secondly you could just remove this method call:
docc.approve(Convert.ToInt32(Session["UserID"]), Convert.ToInt32(Session["DocID"]), Convert.ToInt32(Session["ApproveID"]), Convert.ToString(Session["Login2"]));
and add another parameter in the below code for
AppoveBy
:
cmd.Parameters.Add("@ApproveBy", SqlDbType.VarChar, 50).Value = Convert.ToString(Session["Login2"]);
Let me know if it helps
Azee...