Question: I have a dropdownlist and it is very simple. You click the button to go further you have error if you don't select nothing from DDL. But how i do to not appear the error when the user choose something from the DDL?

Here is the markup:

```
<asp:DropDownList ID="DropDownList1" runat="server" CssClass="jump">
     <asp:ListItem Text="" Value="0"></asp:ListItem>  
     <asp:ListItem Text="Coupé" Value="Coupé" />
     <asp:ListItem Text="Cabriolet" Value="Cabriolet" />
     <asp:ListItem Text="Pickup" Value="Pickup" />   
     <asp:ListItem Text="Kombi" Value="Kombi" />   
     <asp:ListItem Text="Kombi-Coupé" Value="Kombi-Coupé" />  
     <asp:ListItem Text="Minibuss" Value="Minibuss" />
     <asp:ListItem Text="Sedan" Value="Sedan" />    
     <asp:ListItem Text="Skåpbil" Value="Skåpbil" />
     <asp:ListItem Text="SUV" Value="SUV" />                      
     <asp:ListItem Text="Övrig" Value="Övrig" /> 
</asp:DropDownList>
<p id="err" runat="server"></p>  

```

and code-behind:

```
if (DropDownList1.SelectedIndex == 0)
{
    err.InnerHtml = "<span style='font: normal bold 11px/100% Arial, Verdana, Sans-Serif; color: Red'>Du måste välja Fordonstyp!</span>";
    return;
}

```

Thank you so much in advance

Answer: 
As simple as this:

```
err.InnerHtml = "";
if (DropDownList1.SelectedIndex == 0)
    {
        err.InnerHtml = "<span style='font: normal bold 11px/100% Arial, Verdana, Sans-Serif; color: Red'>Du måste välja Fordonstyp!</span>";
        return;
    }

```

This will hide the error by default, then show it only if needed.

**Edit**: to support more than one drop down wrap it nicely with a function first:

```
private bool HandleDropDownError(DropDownList oDDL, HtmlGenericControl oErrorControl, string strErrorText)
{
    oErrorControl.InnerHtml = "";
    if (oDDL.SelectedIndex == 0)
    {
        oErrorControl.InnerHtml = "<span style='font: normal bold 11px/100% Arial, Verdana, Sans-Serif; color: Red'>" + strErrorText + "</span>";
        return false;
    }
    return true;
}

```

Now just use the same error label to show error for any drop down, and have such code in the `Page_Load`:

```
if (!HandleDropDownError(DropDownList1, err, "Du måste välja Fordonstyp!"))
    return;
if (!HandleDropDownError(DropDownList2, err, "Du måste välja matta!"))
    return;
if (!HandleDropDownError(DropDownList3, err, "Du måste välja byggnad!"))
    return;

```
I took your code modified it to work. (at least what I think you are looking for)

```
   <asp:DropDownList ID="DropDownList1" runat="server" CssClass="jump" AutoPostBack="true">

```

and here

```
if (DropDownList1.SelectedIndex == 0)
{
    err.InnerHtml = "<span style='font: normal bold 11px/100% Arial, Verdana, Sans-Serif; color: Red'>Du måste välja Fordonstyp!</span>";
    return;
}else {err.InnerHtml = ""}

```