Thursday, 10 January 2013

Adding TabPanels Programatically in ASP.NET AJAX Vb.NET


Adding TabPanels Programatically in ASP.NET AJAX VB.NET



Step 1) Create WebPage .aspx

Step 2)  Include following References
              System.Data;
              System.Data.SqlClient;


Step 3)  Build DataSet using  AdventureWorks Database.
               Here I am using 2 tables 
                1.SalesPerson
                2.Employee

 Private  Sub BuildDataSet()
        Dim conn As SqlConnection =  New SqlConnection("server = .\sqlexpress2012
                            database=AdventureWorks2012
                            trusted_connection=yes")

        SqlDataAdapter ad = New SqlDataAdapter("select * from
(AdventureWorks2012).(Sales).(SalesPerson) as SalesPerson "+
        "select * from (AdventureWorks2012).(HumanResources).
(Employee) as Employee",
            conn)

        ad.Fill(ds)
        conn.Close()

 End Sub


Step 4)    Programatically Creating a GridView in ASP.NET using VB.NET

 void AddTabPanels()
        {
        TabContainer1.Tabs.Clear()

        Dim tb As DataTable
        For Each tb In ds.Tables
        Dim panel As AjaxControlToolkit.TabPanel =  New AjaxControlToolkit.TabPanel()
        panel.HeaderText = tb.TableName
        Dim view As GridView =  New GridView()
        view.EmptyDataText = "No data found"
        view.ShowHeaderWhenEmpty = True
        view.DataSource = tb
        view.DataBind()
        view.AlternatingRowStyle.BackColor = System.Drawing.Color.Teal
        view.AlternatingRowStyle.ForeColor = System.Drawing.Color.Wheat
        panel.Controls.Add(view)
        TabContainer1.Tabs.Add(panel)

        Next
 
Note: Every PostBack Dynamic controls needs to be created.
Step 5) Bind in Page_Load()

        Dim ds As DataSet =  New DataSet()
        Protected  Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
            BuildDataSet()
            AddTabPanels()
        End Sub


Step 6) Run the Web page.



Adding TabPanels Programatically in ASP.NET AJAX C#,Creating tabpanels in ajax


Adding TabPanels Programatically in ASP.NET AJAX C#/Vb.NEt,Creating tabpanels in ajax





 




Tags:Adding TabPanels Programatically in ASP.NET AJAX VB.NET,AJAX Tabcontainer in VB.NET, Adding  Tab Panels Programatically, Adding TabPanels Dynamically. AJAX TAB Container Example, AJAX TABCONTAINER Tutorial