Hi akhter,
1. InsertRows does not return a value that you are using to Increment. If you want to increment you need to to change the return type of the method.
2. You have declare ResultValue as string variable. You need to change it to int type.
Check the update code.
private int InsertRows(string s_No, string v_Name, string rate, string s_liter, string entryDate)
{
int i = 0;
//con.Open();
using (SqlCommand cmd = new SqlCommand("Sp_InsertInvM", con))
{
....
i = cmd.ExecuteNonQuery();
}
return i;
}
Then use the method like below.
string s_No, v_Name, rate, s_liter, entryDate;
int ResultValue = 0;
foreach (DataRow row in dt.Rows)
{
s_No = (row["S_No"].ToString());
v_Name = (row["V_Name"].ToString());
rate = (row["Rate"].ToString());
s_liter = (row["S_liter"].ToString());
entryDate = (row["EntryDate"].ToString());
ResultValue += this.InsertRows(s_No, v_Name, rate, s_liter, entryDate);
}
if (ResultValue == dt.Rows.Count)
{
// Response.Redirect("BalePack.aspx");
Response.Redirect("Packrpt.aspx?PID=" + I_ID + "");
}
else
{
Response.Write("<script>alert('Not Save'</script>");
}