How to pass a Datatable back from a user control to its hosting page?

Posted on 2006-05-02
Last Modified: 2012-06-27
How to pass a Datatable back from a user control to its hosting page?

I added a property in my user control page:

    Private objDataTable as DataTable

    .... set objDataTable value somewhere ....

    Public ReadOnly Property Shipments() As DataTable
            Return objDataTable
        End Get
    End Property

On hosting page, I used ucShip to refer my User Control, and tried to get the DataTable:
    Dim oTable as DataTable = ucShip.Shipments

Got error "object variable or with block variables not set"

Please help!
Question by:dshi15
    1 Comment
    LVL 7

    Accepted Solution

    You need to use find control to get ucShip.
    Dim oTable as DataTable
    Dim ucShip as System.Web.UI.Control
    ucShip = Me.FindControl("WhatEverTheNameISofYourUserControl");
    if not isNothing(ucShip) then
        DataTable = ucShip.Shipments
    end if

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Suggested Solutions

    Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    728 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now