Address form Demo (VB.net) : Address form « Components « ASP.Net

Home
ASP.Net
1.ADO.net Database
2.Ajax
3.Asp Control
4.Collections
5.Components
6.Data Binding
7.Development
8.File Directory
9.HTML Control
10.Language Basics
11.Login Security
12.Mobile Control
13.Network
14.Page
15.Request
16.Response
17.Server
18.Session Cookie
19.Sitemap
20.Theme Style
21.User Control and Master Page
22.Validation by Control
23.Validation by Function
24.WebPart
25.WPF
26.XML
ASP.Net » Components » Address form 
Address form Demo (VB.net)

<%--
Code revised from 

ASP.NET Tips & Techniques (Paperback)
by Greg Buczek 


# Publisher: McGraw-Hill/Osborne Media; 1st edition (May 212002)
# Language: English
# ISBN: 0072225149

--%>   
<%@ Page Language=VB Debug=true %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.OLEDB" %>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    If Not IsPostBack Then
        Dim DBConn as OleDbConnection
        Dim DBCommand As OleDbDataAdapter
        Dim DSPageData as New DataSet
        DBConn = New OleDbConnection_
            "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
            "DATA SOURCE=" _
            & Server.MapPath _
            ("StoresDB.mdb;"))
        DBCommand = New OleDbDataAdapter _
            ("Select Distinct State From Stores " _
            "Order By State", DBConn)
        DBCommand.Fill(DSPageData, _
            "States")
        ddlStates.DataSource = _
            DSPageData.Tables("States").DefaultView
        ddlStates.DataBind()
    End If
End Sub
Sub ddlState_Changed(Sender As Object, E As EventArgs)
    Dim DBConn as OleDbConnection
    Dim DBCommand As OleDbDataAdapter
    Dim DSPageData as New DataSet
    DBConn = New OleDbConnection_
        "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
        "DATA SOURCE=" _
        & Server.MapPath _
        ("StoresDB.mdb;"))
    DBCommand = New OleDbDataAdapter _
        ("Select Distinct City From Stores " _
        "Where State = '" & ddlStates.SelectedItem.Text _
        "' Order By City", DBConn)
    DBCommand.Fill(DSPageData, _
        "Cities")
    ddlCities.DataSource = _
        DSPageData.Tables("Cities").DefaultView
    ddlCities.DataBind()
    ddlCities.Visible = True
    lblMessage3.Visible = True
End Sub
Sub ddlCity_Changed(Sender As Object, E As EventArgs)
    Dim DBConn as OleDbConnection
    Dim DBCommand As OleDbDataAdapter
    Dim DSPageData as New DataSet
    DBConn = New OleDbConnection_
        "PROVIDER=Microsoft.Jet.OLEDB.4.0;" _
        "DATA SOURCE=" _
        & Server.MapPath _
        ("StoresDB.mdb;"))
    DBCommand = New OleDbDataAdapter _
        ("Select StoreName as [Store Name], " _
        "Address From Stores " _
        "Where City = '" _
        & ddlCities.SelectedItem.Text & "' " _
        "And State = '" _
        & ddlStates.SelectedItem.Text & "' " _
        "Order By StoreName", DBConn)
    DBCommand.Fill(DSPageData, _
        "Stores")
    dgStores.DataSource = _
        DSPageData.Tables("Stores").DefaultView
    dgStores.DataBind()
End Sub
</SCRIPT>
<HTML>
<HEAD>
<TITLE>Store Location</TITLE>
</HEAD>
<Body LEFTMARGIN="40">
<form runat="server">
<BR><BR>
<asp:label 
    id="lblMessage2" 
    font-size="10pt"
    font-name="Lucida Console"
    text="Select a State"
    runat="server"
/>
<BR>
<asp:dropdownlist
    id="ddlStates"
    datatextfield="State" 
    autopostback="True"
    onselectedindexchanged="ddlState_Changed"
    runat="server"
/>
<BR><BR>
<asp:label 
    id="lblMessage3" 
    font-size="10pt"
    font-name="Lucida Console"
    text="Select a City"
    visible="False"
    runat="server"
/>
<BR>
<asp:dropdownlist
    id="ddlCities"
    datatextfield="City" 
    autopostback="True"
    onselectedindexchanged="ddlCity_Changed"
    visible="False"
    runat="server"
/>
<BR><BR>
<asp:label 
    id="lblMessage1" 
    font-size="12pt"
    font-bold="True"
    font-name="Lucida Console"
    text="Stores in Your Area"
    runat="server"
/>
<BR><BR>
<asp:datagrid
    id="dgStores" 
    runat="server" 
    autogeneratecolumns="True"
/>
</form>
</BODY>
</HTML>
           
       
StoresDB.zip( 8 k)
Related examples in the same category
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.