mardi 29 mai 2018

How to Use Multiple IF Conditions in C#

I want to store multiple values in different SESSIONS for that I have Multiple If Conditions in VB Code that Works fine

   If roleRow.Item("Code").ToString() = "101" Then 'Admin Settings
                            If roleRow.Item("Active") = True Then Session("101") = True Else Session("101") = False
                        End If
                        If roleRow.Item("Code").ToString() = "102" Then 'Summaries / Reports
                            If roleRow.Item("Active") = True Then Session("102") = True Else Session("102") = False
                        End If
                        If roleRow.Item("Code").ToString() = "103" Then 'Invoices List
                            If roleRow.Item("Active") = True Then Session("103") = True Else Session("103") = False
                        End If

**but same code structure doesn't work in C# ** It evaluate only first IF Condition and rest conditions it shows the same value as first IF Condition. Any Suggestions how to solve this.....

if (dRow["Code"].ToString() == "104" && (Boolean)dRow["Active"] == true)
                {
                    Session["104"] = true;
                }
                else
                {
                    Session["104"] = false;
                }

                if (dRow["Code"].ToString() == "105" && (Boolean)dRow["Active"] == true)
                {
                    Session["105"] = true;
                }
                else
                {
                    Session["105"] = false;
                }

                if (dRow["Code"].ToString() == "106" && (Boolean)dRow["Active"] == true)
                {
                    Session["106"] = true;
                }
                else
                {
                    Session["106"] = false;
                }

Aucun commentaire:

Enregistrer un commentaire