check if radiobuttonlist exsits

magmo

Member
Joined
Oct 19, 2006
Messages
14
Programming Experience
1-3
Hi

I have a radiobuttonlist that gets its values from a sqlserver database. But its not always it gets any values, and therfore sometimes isn't displayed on my aspx page. How can I check if the radiobuttonlist exsits in my code behind?


Best regards
 
VB.NET:
Dim x As Control = e.Item.FindControl("controlname")
If Not x Is Nothing Then 
  'exists
End If
Thread moved to ASP.Net section.
 
Hi John


I have added thees lines...

HTML:
Dim x As RadioButtonList = CType(Page.FindControl("RadioButtonList2"), RadioButtonList)
If Not x Is Nothing Then
 Response.Write("Control exsits!")
End If

But I always get the True on this condition...
 
Ok, I haven't tested the scenario, so it must be generating the RadioButtonList control even if there are no items. You can check the RBL.Items.Count then.
 
Back
Top