Home arrow ASP.NET arrow Page 2 - IE Web Controls in VB.NET
ASP.NET

IE Web Controls in VB.NET


The web interface is becoming more advanced...In this article Himanshu shows us a simple example of how to use the TreeView and TabStrip IE Web Controls with VB.NET.

Author Info:
By: Himanshu Dhami
Rating: 4 stars4 stars4 stars4 stars4 stars / 51
February 25, 2003
TABLE OF CONTENTS:
  1. · IE Web Controls in VB.NET
  2. · TreeView Control
  3. · TabStrip Control
  4. · Conclusion

print this article
SEARCH DEVARTICLES

IE Web Controls in VB.NET - TreeView Control
(Page 2 of 4 )

Once you've downloaded and installed IE Web Controls, create a new ASP.NET application and make sure the TreeView control is in the toolbox.

Add the treeview control to your aspx form and in HTML view it will look something like this:

<%@ Page Language="vb" AutoEventWireup="false" Codebehind="treeview.aspx.vb" Inherits="appname.treeview"%>
<%@ Register TagPrefix="iewc" Namespace="Microsoft.Web.UI.WebControls" Assembly="Microsoft.Web.UI.WebControls, Version=1.0.2.226, Culture=neutral, PublicKeyToken=31bf3856ad364e35" %>
<form id="Form2" method="post" runat="server">
     <iewc:treeview id="tvGroups" runat="server" Width="100%" BorderWidth="0px" Height="100%"></iewc:treeview>
</form>


So here a TreeView is created on your page and we will use "tvgroups" to refer it later.

Now the code behind page (Treeview.aspx.vb):

Imports Microsoft.Web.UI.WebControls
Imports System.Data.SqlClient
Public Class Treeview
    Inherits System.Web.UI.Page
    Protected WithEvents tvGroups As Microsoft.Web.UI.WebControls.TreeView
    Dim connString = "your connection string for database"
    Dim myConnection As New SqlConnection(connString)
    Dim dtid, dtname As String


Here I am building the tree view with the values from the database, so now the remaining code is working with DataSets, DataRows and DataTables. If you know how to use them itíll be easy for you, if not then thereís plenty of documentation about how to use them.

The following code goes in the Page_Load event/method:

If Not Page.IsPostBack Then
  Dim mysqladapter As New SqlDataAdapter()
  Dim mydataset As New DataSet()
  Dim pNode, pChild As TreeNode
  Dim dttable As DataTable
  Dim dtrow As DataRow
  Dim countrow As Integer
  Dim dtcolumn As DataColumn
  mysqladapter = New SqlDataAdapter("Fetch_departments", myConnection)
  mysqladapter.Fill(mydataset, "tbl_no_sales_days")
  Dim myDataView As DataView = New DataView(mydataset.Tables("tbl_no_sales_days"))
  myDataView.Sort = "departmentregionid"
  countrow = myDataView.Count
  pNode = New TreeNode()
  pNode.Text = "ALL DEPARTMENTS"
  pNode.NavigateUrl = ""
  tvGroups.Nodes.Add(pNode)
  For Each dttable In mydataset.Tables
    For Each dtrow In dttable.Rows
      dtid = dtrow(0)
      dtname = dtrow(1)
      pChild = New TreeNode()
      pChild.NavigateUrl = "http://www.oxx.no"
      pChild.Text = dtname
      pChild.ID = dtid
      pNode.Nodes.Add(pChild)
    Next
  Next
End If


In the code above "Fetch_departments" is a stored procedure which returns regions and departments.

The output will be something like this:

ALL DEPARTMENTS
--REGION1
-----DEPT1
-----DEPT2
-----DEPT3
--REGION2
-----DEPT1
-----DEPT2
-----DEPT3
...

blog comments powered by Disqus
ASP.NET ARTICLES

- How Caching Means More Ca-ching, Part 2
- How Caching Means More Ca-ching, Part 1
- Reading a Delimited File Using ASP.Net and V...
- What is .Net and Where is ASP.NET?
- An Object Driven Interface with .Net
- Create Your Own Guestbook In ASP.NET
- HTTP File Download Without User Interaction ...
- Dynamically Using Methods in ASP.NET
- Changing the Page Size Interactively in a Da...
- XML Serialization in ASP.NET
- Using Objects in ASP.NET: Part 1/2
- IE Web Controls in VB.NET
- Class Frameworks in VB .NET
- Cryptographic Objects in C#: Part 1
- Sample Chapter: Pure ASP.Net

Watch our Tech Videos 
Dev Articles Forums 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Contact Us 
Site Map 
Privacy Policy 
Support 

Developer Shed Affiliates

 




© 2003-2017 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap
Popular Web Development Topics
All Web Development Tutorials