Welcome Guest Search | Active Topics | Sign In | Register

Dynamic Built Tabstrip with PageView attaching Dynamic Usercontrols Options
dindryte
Posted: Wednesday, November 25, 2015 3:40:21 PM
Rank: Newbie
Groups: Member

Joined: 11/24/2015
Posts: 2
I am using the tabstrip and multipage controls from essential objects. My goal is to dynamically build the tabstrip and pageviews based upon a dataset retrieved from a database.

So far the dynamic build is working, but I am having a issue with adding a usercontrol to each pageview.

This is my code so far...
Code: Visual Basic.NET
Dim dt As New DataTable()
    Dim ds As New DataSet()
    Dim dr As DataRow
    Dim ts As New EO.Web.TabStrip
    Dim mp As New EO.Web.MultiPage
    ts = tsProgramMenu
    mp = mpProgramMenu

    dt = bc.getGrantProgram(strConnection, strGrantProgramId, strActive)

    For Each dr In dt.Rows
        'MULTI PAGE PAGEVIEWS
        Dim p As New EO.Web.PageView
        p.ID = "pv" & dr.Item(1).ToString

        mp.PageViews.Add(p)
        'TOP ROW TAB ITEMS
        Dim x As New EO.Web.TabItem
        x.Text.Html = dr.Item(1).ToString
        x.ItemID = "ti" & dr.Item(1).ToString
        x.PageViewID = p.ID
        ts.TopGroup.Items.Add(x)

    Next


n the page source I can see the pageviews being created.
Code: HTML/ASPX
<table id="ctl00_MainContent_pvHMGP" border="0" cellpadding="0" cellspacing="0" style="display:none;">
    <tr>
        <td valign="top"></td>
    </tr>
</table>


I am just having trouble adding the usercontrol to the pageview.

Thanks for any and all assistance!!!
eo_support
Posted: Wednesday, November 25, 2015 5:07:18 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Hi,

PageView is a container control. So you can simply use PageView.Controls.Add to add child controls into the PageView.

You do need to be very careful if your dynamic control also needs to handle event. You must make sure your control tree is exactly the same when the page renders initially and when the page posts back. Otherwise your server event won't fire properly. This is not a limitation of our controls --- this is just how ASP.NET works. So if you run into problems with server events, you can search online for more information about dynamically creating control and handling server event and you should be able to find additional information about that.

Thanks!
dindryte
Posted: Monday, November 30, 2015 11:20:45 AM
Rank: Newbie
Groups: Member

Joined: 11/24/2015
Posts: 2
That works, thanks

Final code in case it helps another...

Code: Visual Basic.NET
Dim dt As New DataTable()
        Dim ds As New DataSet()
        Dim dr As DataRow
        Dim ts As New EO.Web.TabStrip
        Dim mp As New EO.Web.MultiPage
        ts = tsProgramMenu
        mp = mpProgramMenu

        dt = bc.getGrantProgram(strConnection, strGrantProgramId, strActive)

        For Each dr In dt.Rows
            'MULTI PAGE PAGEVIEWS
            Dim p As New EO.Web.PageView
            Dim uc As New UserControl
            Dim strUserControl As String

            strUserControl = dr.Item(1).ToString & ".ascx"
            uc.ID = "uc" & dr.Item(1).ToString
            p.ID = "pv" & dr.Item(1).ToString
            p.Controls.Add(Page.LoadControl(strUserControl))

            mp.PageViews.Add(p)
            'TOP ROW TAB ITEMS
            Dim x As New EO.Web.TabItem
            x.Text.Html = dr.Item(1).ToString
            x.ItemID = "ti" & dr.Item(1).ToString
            x.PageViewID = p.ID
            ts.TopGroup.Items.Add(x)

        Next
eo_support
Posted: Monday, November 30, 2015 11:23:48 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,080
Great. Thanks for sharing!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.