Web User Controls - How to reference objects on them?

Discussion in 'ASP .Net' started by Hanover, Sep 9, 2005.

  1. Hanover

    Hanover Guest

    What I want to do seems like it should be simple:

    1. Create a new web control

    2. Place a datagrid on it and set it's ID to dgFiles

    3. Assign it's datasource.

    Sub ShowFiles()

    Dim ds as dataset

    ....code here...

    dgFiles.DataSource = ds

    End Sub

    When I assign it's datasource, it is saying dgFiles is not set to
    anything which is stupid since intellisense is acting like it's there
    and ready to be used.

    So how do I reference to a control on my Web User Control?
    Hanover, Sep 9, 2005
    1. Advertisements

  2. Hanover

    john_teague Guest

    Are you trying to set is datasource on the aspx page that has the
    control? If so, make the datagrid a public member of the control
    instead of protected.
    john_teague, Sep 9, 2005
    1. Advertisements

  3. Hanover

    Guest Guest

    are you doing this in the control or the page containing the control?
    From the controls codebehind you should easily be able to do it, from the
    page you will have to do some extra work.
    Guest, Sep 9, 2005
    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.