ASP Code
  Home arrow ASP Code arrow Relational DropDownList Using VB.NET
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Silverlight  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
ASP Web Hosting  
ASP.NET Web Hosting 
Windows Web Hosting
 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
ASP CODE

Relational DropDownList Using VB.NET
By: aspfree
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 112
    2003-07-16

    Table of Contents:

    Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Relational DropDownList Using VB.NET Code Example. In this code, we illustrate three steps:
    Step 1. Copy and paste the code below on to the newly created aspx file
    Step 2. Add <appSettings> tag to the existing web.config
    Step 3. Make sure you have Northwind database install in your system******************************

     <!-- ASPX Page --><!-- Step 1. Copy and paste the code below on to the newly created aspx file --><!-- Step 2. Add <appSettingstag to the existing web.config --><!-- Step 3. Make sure you have Northwind database install in your system --><%@ Import Namespace="System.Data" %><%@ Import Namespace="System.Data.SqlClient" %>
    <
    SCRIPT language=VB runat="server">

    Public 
    Sub Page_Load(Source As ObjectAs EventArgs)

    If 
    Not IsPostBack Then

    Dim _Conn 
    As SqlConnection
    Dim _Command 
    As SqlCommand
    Dim _Reader 
    As SqlDataReader
    Dim SQL 
    As String

    SQL 
    "select * from Region"

    _Conn GetConnection()

    _Command = new SqlCommand(SQL_Conn)

    _Reader _Command.ExecuteReader()

    Regions.Items.Add(new ListItem("Select Region...""0")) 

    While 
    _Reader.Read()
    Regions.Items.Add(new ListItem(_Reader("RegionDescription").ToString(), _Reader("RegionID").ToString()))
    End While

    Territory.Items.Add(new ListItem("Select Territory...""0"))

    End If

    End Sub

    Function GetConnection() As SqlConnection
    Dim _Connection 
    As SqlConnection
    Dim ConnStr 
    As String

    ConnStr 
    ConfigurationSettings.AppSettings("ConnectionString")

    _Connection = new SqlConnection(ConnStr)
    _Connection.Open()

    Return 
    _Connection
    End 
    Function 


    Sub OnSelectedRegionIndexChanged(Source As ObjectAs EventArgs)
    Dim _Region As Integer

    _Region 
    Regions.SelectedItem.Value

    If _Region 0 Then 

    Dim _Conn 
    As SqlConnection
    Dim _Command 
    As SqlCommand
    Dim _Reader 
    As SqlDataReader
    Dim SQL 
    As String

    SQL 
    "select * from Territories where RegionID ='" _Region "'"

    _Conn GetConnection()

    _Command = new SqlCommand(SQL_Conn)

    _Reader _Command.ExecuteReader()

    Territory.Items.Clear()
    Territory.Items.Add(new ListItem("Select Territory...""0"))


    While 
    _Reader.Read()
    Territory.Items.Add(new ListItem(_Reader("TerritoryDescription").ToString(), _Reader("TerritoryID").ToString()))
    End While

    txtRegion.Text Regions.SelectedItem.Text 
    txtTerritory
    .Text "" 
    Else

    Territory.Items.Clear()
    Territory.Items.Add(new ListItem("Select Territory...""0"))
    txtRegion.Text ""
    txtTerritory.Text ""

    End If 

    End Sub

    Sub OnSelectedTerritoryIndexChanged
    (Source As ObjectAs EventArgs)

    Dim _Territory As Integer

    _Territory 
    Territory.SelectedItem.Value

    If _Territory 0 Then

    txtTerritory
    .Text Territory.SelectedItem.Text
    Else
    txtTerritory.Text ""
    End If

    End Sub

    </SCRIPT>

    <FORM runat="server"><asp:DropDownList id=Regions runat="server" 
    OnSelectedIndexChanged="OnSelectedRegionIndexChanged" 
    AutoPostBack="True"></asp:DropDownList>
    <asp:DropDownList id=Territory runat="server" 
    OnSelectedIndexChanged="OnSelectedTerritoryIndexChanged" 
    AutoPostBack="True"></asp:DropDownList>
    <asp:Label id=txtRegion runat="server"></asp:Label>
    <asp:Label 
    id=txtTerritory 
    runat="server"></asp:Label></FORM><!-- Web.Config --><CONFIGURATION><APPSETTINGS><ADD 
    value="Server=(local)NetSDK;uid=sa;pwd=;database=Northwind" 
    key="ConnectionString" /></APPSETTINGS></CONFIGURATION>


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

    More ASP Code Articles
    More By aspfree

     

    IBM® developerWorks developerWorks - FREE Tools!


    NEW! Calling all CC Power Users – and those that would like to be!

    Join this Rational Talks to You teleconference, featuring Paul Boustany and Mark Krasovich, to speak to the experts about becoming a Rational ClearCase power user. Get a chance to ask your questions and learn tips and tricks for using Rational ClearCase in Agile development
    FREE! Go There Now!


    NEW! Did you say mainframe? e-kit

    Learn how you can extend modern application lifecycle management to IBM System z through the IBM Rational Software Delivery Platform (SDP). The Did you say mainframe? e-kit includes podcasts, webcasts, tutorials, white and red papers, demos, and articles designed to help ease the challenges of modernizing your enterprise. This complimentary kit for mainframe developers is a practical, how-to guide for making the most of an existing development environment, including the skills and infrastructure already in place at an established enterprise.
    FREE! Go There Now!


    NEW! Evaluate IBM Lotus Sametime Standard V8.0

    Visit IBM developerWorks to download a free trial of the latest release of IBM Lotus Sametime Standard V8.0. Lotus Sametime Standard V8.0 is a platform for unified communications and collaboration that combines security features with an extensible, open solution including integrated Voice over IP, geographic location awareness, mobile clients, and a robust Business Partner community offering telephony and video integration.
    FREE! Go There Now!


    NEW! Evaluate Rational Business Developer V7.1

    Visit IBM developerWorks to download a free trial version of IBM Rational Business Developer V7.1. Rational Business Developer offers rapid and simplified development of business applications and services through Enterprise Generation Language (EGL) tools, generating Java or mainframe solutions while shielding developers from technical complexities.
    FREE! Go There Now!


    NEW! Hello World: Monitor a simple business process using WebSphere Business Monitor V6.0.2

    This tutorial shows new users of IBM WebSphere Business Monitor Version 6.0.2 how to perform the "Hello World" equivalent for monitoring business process applications. It is intended to help you get familiar with the capabilities of the product.
    FREE! Go There Now!


    NEW! Maintaining QoS and Process Integrity in an SOA Environment

    This webcast outlines the best practices that must be instituted to gain the maximum benefit from SOA while maintaining high quality of service. Whether you are deploying new applications or managing and monitoring your existing infrastructure, learn how you can ensure high quality of services with SOA based solutions from IBM. All registrants who attend this live Web Seminar will receive complimentary access to a white paper titled “Maintaining QoS in an SOA Environment”.
    FREE! Go There Now!


    NEW! Successful Change and Release Management for .NET

    Join this webcast to discover the key requirements for successful change and release management. Learn how to extend your .NET environment to improve productivity and collaboration, and address core problems afflicting team development. In this webcast, we’ll review typical challenges faced by customers and how to resolve them with the IBM Rational Change and Release Management solution, including Rational ClearCase, Rational ClearQuest and Rational Build Forge. Replay is available for 9 months.
    FREE! Go There Now!


    NEW! Try the IBM SOA Sandbox for People

    Visit IBM developerWorks to try the IBM SOA Sandbox for people. The SOA Sandbox for people provides a trial environment with the necessary tooling and components required to enable consistent human and process interaction and collaboration, showing how you can improve user experience and business productivity.
    FREE! Go There Now!


    NEW! Using IBM Rational Developer for System z and IBM Rational ClearCase together to manage application development

    Whether you are creating new applications or modifying existing ones, managing integration of new components with traditional z/OS elements is a critical part of building and deploying modern applications. Listen to this webcast to see how IBM can help you optimize your development process using an IDE like Rational Developer for System z that integrates with management tools, such as ClearCase to manage your application development on mainframes.
    FREE! Go There Now!


    NEW! Webcast: WebSphere Process Server

    WebSphere Process Server delivers a unique integration framework that simplifies existing IT resources. Often, as IT assets grow to support business demand, so too does their complexity and manageability. In this webcast, we’ll discuss how WebSphere Process Server helps deliver an SOA infrastructure that provides a common model to orchestrate, mediate, connect, map, and execute the underlying IT functions. Discover how WebSphere Process Server simplifies integration of business processes by leveraging existing IT assets as reusable services without the complexities of traditional integration methodologies.
    FREE! Go There Now!



    All FREE IBM® developerWorks Tools!

    ASP CODE ARTICLES

    - ASP Forms
    - ASP: The Beginning
    - Getting Remote Files With ASP Continued
    - Inbox and Outbox Manipulation in ASP
    - Relational DropDownList Using VB.NET
    - Ad Tracking URL Hits
    - Use ViewState to display one record per page...
    - Send Email using ASP.NET formatted in HTML
    - ASP File Explorer
    - ASP/XML Interview questions by Srivatsan Sri...
    - Various methods of setting Date values to a ...
    - Conditional DataGrid Item and using checkbox...
    - Fill .NET Listbox with SQL DataReader
    - Filling Dropdown box using Code-Behinds in C#
    - FLAMES code sample written in .NET What is F...





    © 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
    Stay green...Green IT