Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Help guys, Only else statement runs in if else statement

$
0
0
Hi guys, (i am new to c#), the underneath code has been cracking my head for 2 days now, could some help.
When i debug this code, once it gets to the first and second if statements, it will jump to else statements, but the if statement for the boolean works fine (I dont seems to get why). Thanks guys

 private void DisplayCustomer(string Customer)
        {
            ClsSqlServer obj = new ClsSqlServer();
            DataSet objdataset = obj.getCustomer(Customer);

            // Bind the data to UI
            string strCustomerName = objdataset.Tables[0].Rows[0][0].ToString();
            string strCountryName = objdataset.Tables[0].Rows[0][1].ToString();
            string strgender = objdataset.Tables[0].Rows[0][2].ToString();
            string strHobbies = objdataset.Tables[0].Rows[0][3].ToString();
            bool Married = Convert.ToBoolean(objdataset.Tables[0].Rows[0][4]);
          
            // if (objdataset.Tables[0].Rows[0][4] != DBNull.Value)
            //{
            //    Married = Convert.ToBoolean(objdataset.Tables[0].Rows[0][4]);
            //}

            TxtCustomerName.Text = strCustomerName;
            drpCountry.Text = strCountryName;

            if ((strgender.Length == 0) || (strgender == "Female"))
            {
                radioFemale.Checked = true;
                
            }
            else
            {
                radioMale.Checked = true;
            }

            if (strHobbies == "Swimming")
            { 
                chkbSwimming.Checked = true;
                
            }
            else 
            {
                chkCoding.Checked = true;    
            }
           
            if (Married == false)
            {
                radioSingle.Checked = true;
            }
            else
            {
                radioMarried.Checked = true;
            }
         
        }

Viewing all articles
Browse latest Browse all 51036

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>