I'm trying to loop through my dropdown controls on my aspx page here is the code I have:
Private Sub PopulateDropDowns(ByVal dropDownName As String)
Dim dropDown As DropDownList = CType(Me.FindControl(dropDownName), DropDownList)
dropDown.Items.Add(New ListItem With {.Text = "Somedata", .Value = "123"})
End Sub
I'm getting a "Object reference not set to an instance of an object"
Here is my aspx page (I've search through other answer which talk about the hierarchy of controls which I've tried - but failed)
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="SelectTeam.aspx.vb" Inherits="FCO.SelectTeam" %>
<asp:DropDownList ID="ddOpenBrd1" runat="server"></asp:DropDownList>
<asp:DropDownList ID="ddOpenBrd2" runat="server"></asp:DropDownList>
<asp:DropDownList ID="ddOpenBrd3" runat="server"></asp:DropDownList>
<asp:DropDownList ID="ddOpenBrd4" runat="server"></asp:DropDownList>
</div>