If Null display button in C# and ASP.net

Hi everyone,

I am reading a few fields I have stored and every time I come back to this page, I need to see a different button depending on the value of the "status" field.

Here is the code.

 private void Bind_Data14()
    {
        if (!IsEmpty(Request.QueryString["r"]))
        {

            SqlCommand cmd14R = new SqlCommand("sp_LA_14day", myConnection);
            cmd14R.CommandType = CommandType.StoredProcedure;
            cmd14R.Parameters.Add(new SqlParameter("@ReferralID", Request.QueryString["r"]));
            SqlDataReader dr = null;

            myConnection.Open();
            dr = cmd14R.ExecuteReader();

            if (dr.Read())
            {
                txtReferralID.Text = dr["ID"].ToString();
                txtDischargeDate14.Text = String.Format("{0:MM/dd/yyyy}", dr["DischargeDate"]);
                txtDay14Date.Text = String.Format("{0:MM/dd/yyyy}", dr["Day14Date"]);
                ddlStatus14.SelectedValue = dr["Status"].ToString();

//this is what i need to make it work,
                if (dr["Status"].ToString() ==  null)
                {
                    Day14_Btn.Text = "Submit Day 14 status:";
                }
                else
                {
                    Day14_Btn.Text = "Submitted/Update";
                    Day14_Btn.Attributes["style"] = "color:red; font-weight:bold;";
                }

                txtStatusOther14.Text = dr["StatusOther"].ToString();

            }
           
            if (dr != null)
                dr.Close();

        }

        myConnection.Close();
    }
shpresaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

shpresaAuthor Commented:
I did try this as well

 if  (ddlStatus14.SelectedValue == null)
                {
                    Day14_Btn.Text = "Submit Day 14 status:";
                }
                else
                {
                    Day14_Btn.Text = "Submitted/Update";
                    Day14_Btn.Attributes["style"] = "color:red; font-weight:bold;";
                }

                txtStatusOther14.Text = dr["StatusOther"].ToString();


didn't work.
0
unknown_routineCommented:
If you are comparing versus Database null values, then you have to use DBNULL class.



For example:


if (! DBNull.Value.Equals(row[fieldName])) 
           {

           }

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
shpresaAuthor Commented:
Excellent. Thnx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP.NET

From novice to tech pro — start learning today.