Search code examples
asp.netvb.netradiobuttonlist

RadioButtonList FindByValue Problems


I seem to be having problems with finding a specific value in a radio button list.

So if I have Radio Button List like this;

[ID]  [Value]
 1    Apple
 2    Orange
 3    Pear
 4    Banana

I want to use vb.net code behind to see if an item exists. So I thought I could do this;

Dim v as Integer = 3
if rdoTheTest.Items.FindByValue(v) = True Then Msgbox("I Found you")

Problem is I get "Operator = is not defined for types ListItem and integer", am I using this correctly.


Solution

  • You need to change your code like

    Dim v as Integer = 3
    if rdoTheTest.Items.FindByValue(v) IsNot Nothing Then Msgbox("I Found you")