How to hide an empty databound DropDownList

85 views Asked by At

I have a databound DropDownList and I need a code that will only show the DropDownList if there is a value in the Database, if the there is no value/empty DropDownlist it should not be visible.

I tried:

   if (ddlFruits.Items.Count == 1)
     {
         ddlFruits.Visible = false;
     }
     else
     {
         ddlFruits.Visible = true;

     }

1

There are 1 answers

1
mybirthname On
ddlFruits.Visible = ddlFruits.Items.Count > 0