Link to home
Start Free TrialLog in
Avatar of mattlaltman
mattlaltmanFlag for United States of America

asked on

Accessing controls within a FormView and Panel

This is probably easy but I can't figure it out (newbie).  I have a Drop down list that's located within a FormView and within a panel.  When I try to access the control from the code behind page, it doesn't recognize it.  I'm assuming it's because it's within other controls.  I'm not sure what the proper way is to access it.  

Thanks for your help in advance!
Here is my asp.net code:
<asp:FormView
    id="frmCreateDist"
    DataSourceID = "srcCreateDist"
    DefaultMode = "Insert"
    Runat="server">
    <InsertItemTemplate>
    
    <asp:Panel 
        ID="Panel1" 
        GroupingText="Create Dist"
        runat="server">

        <br />

        <asp:DropDownList 
            ID="ddlStateList" 
            runat="server"/>


    </asp:Panel>
   </InsertItemTemplate>
</asp:FormView>



Here is my code behind page.  ddlStateList is unrecognizable:


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        ddlStateList.DataSource = StateManager.getStates()
        ddlStateList.DataTextField = "FullAndAbbrev"
        ddlStateList.DataValueField = "Name"
        ddlStateList.DataBind()
    End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Saqib Khan
Saqib Khan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mattlaltman

ASKER

thank you!!