Hi,
I am having some problem using nested if else in C# project. I have no idea why it is always executing the Save() function. I don't want to execute the save() function if the (dr.Read()) is true.
Here is the code:
protected void BtnSave_Click1(object sender, EventArgs e)
{
string vDrpListProblemStatusID;
vDrpListProblemStatusID = DrpListProblemStatusID.SelectedValue.ToString();
if (vDrpListProblemStatusID == "5" || vDrpListProblemStatusID == "6")
{
string sql;
sql = "select * from Recommendations2 where Status not in (3,4)and Problem_ID = " + TID;
SqlDataReader dr = gv.GetDRsql(sql);
if (dr.Read())
{
lblMsg.Text = "You have to close all Recommendations.";
lblMsg.Visible = true;
}
else
{
save();
Response.Redirect("ProblemsSaveMsg.aspx");
}
}
else
{
save();
Response.Redirect("ProblemsSaveMsg.aspx");
}
}