Radiobuttonlist does not accept on if the SelectedIndx [closed]

0

I have this declared RadioList:

<label>Aprovar</label>
            <asp:RadioButtonList ID="rblAprovar" runat="server" RepeatLayout="Flow" RepeatDirection="Horizontal">
                <asp:ListItem Text="&nbsp;Sim&nbsp;&nbsp;&nbsp;" Value="1" />
                <asp:ListItem Text="&nbsp;Não&nbsp;&nbsp;&nbsp;" Value="0" />
            </asp:RadioButtonList>

And I have this command in my behind:

if(rblAprovar.SelectedIndex = -1)
  {
    vstrMensagem += "- Aprovar não informado.<br>";
  }

This is giving this error:

  

Can not implicitly convert 'int' to 'bool'

I have other Radiobuttonlist with the same if that does not give this error and that they are being programmed the same way. The question is: What could be wrong with this statement? In my opinion nothing.

    
asked by anonymous 26.01.2015 / 16:06

1 answer

3
  

What could be wrong with this statement? In my opinion nothing. @pnet

In your if you are assigning a value to SelectedIndex =, you should use == for Boolean checks.

if(rblAprovar.SelectedIndex == -1)
  {
    vstrMensagem += "- Aprovar não informado.<br>";
  }
    
26.01.2015 / 16:08