In my C # web application, I have three text fields, three drop-down lists and one button.
The button should start the SQL string, which will take the values of what is in the text field, regardless of what is selected, and be inserted into the database. The values entered may not be zero, so I do not want any empty entries. By default, I have a DropDownList, as in the source:
<asp:DropDownList ID="ReadDrop" runat="server">
<asp:ListItem></asp:ListItem>
<asp:ListItem Value="1">Yes</asp:ListItem>
<asp:ListItem Value="0">No</asp:ListItem>
</asp:DropDownList>
So there is an empty entry (default), and then yes / no. Attached are three of these drop-down lists. In my C # code, I have the following to prevent the button from starting when there is an empty entry:
if (UsernameBox.Text != "" & FirstNameBox.Text != "" & LastNameBox.Text != "" /* check for blank dropdownlist? */)
My current problem is that I do not know how to check the drop-down list for an empty entry. I would rather check to see if ReadDrop.Text is empty, but I'm relatively inexperienced in ASP.NET, and I'm wondering if there is a “right” way to do this.
Thank!
Leon source
share