C# .Net - Desperately need help with a ddl in a gridview in a usercontrol

Discussion in 'Software' started by Apolta, Jun 9, 2009.

  1. Apolta

    Apolta

    Joined:
    Jun 9, 2009
    Messages:
    1
    Likes Received:
    0
    I am doing a findcontrol on the dropdownlist, and it does not work in the page_load event, or any other user events, (the ddl always has a selected index of -1 and a null text). The ONLY event that the dropdownlist is found via the findcontrol is the selectedindexchanged event specified in the HTML. I need to be able to find the dropdownlist control earlier - such as in the page_load event or another user event.
    Here's my code:
    HTML: OnSelectedIndexChanged="ddlTEAID_SelectedIndexChanged" -
    protected void ddlTEAID_SelectedIndexChanged(object sender, EventArgs e)
    {

    DropDownList ddlTEAID = (DropDownList)gvTCCGridAE.Rows[0].FindControl("ddlTEAID");
    code...
    }
    However, when I use the same code elsewhere in the ascx.cs file, it doesn't work.
    ALso, I'm having trouble pointing to the parent form associated with the user control, because it is a master template with content holders.

    This is the content holder: ctl00$ContentPlaceHolder1$TCCGrid1$AddEmployee1$gvTCCGridAE$ctl02$ctl00


    How would I code the findcontrol, I know I have to nest the findcontrols.


    How do I code the find control - everything I've tried tells me that the specified name is out of context.
    And also, once I find the control, can you send me a sample of a nested findcontrol?
     
    Last edited: Jun 9, 2009
    Apolta, Jun 9, 2009
    #1
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.