zoukankan      html  css  js  c++  java
  • ASP.NET 两个Dropdownlist控件联动

    两个dropdownlist联动网上代码很多,原理也很简单,这里不再重复了,贴下我自己的代码,希望对给位有帮助(主要关联是在第一个dropdownlist空间的selectindexchanged事件)

    第一个控件绑定:

    Private Sub display()
    Dim cmd As New DataBean ‘我是用的数据库连接类
    Dim ds As New DataSet
    Dim i As Integer
    Dim str As String = "SQL语句"

    cmd.ConnOracle()
    ds = cmd.GetDataSet(str)
    cmd.CloseConn()


    If ds.Tables(0).Rows.Count > 0 Then
    Me.drpplant.Items.Add("")
    For i = 0 To ds.Tables(0).Rows.Count - 1
    Me.drpplant.Items.Add(ds.Tables(0).Rows(i).Item(0).ToString)
    Next
    Else
    Me.lblMsg.Text = "Not Found Any Plant Data!"
    End If

    Me.btnstop.Enabled = False
    Me.List1.Items.Clear()
    Me.List2.Items.Clear()
    End Sub

    第二个控件内容绑定
    Private Sub downlocation(ByVal plant As String)
    Dim cmd As New DataBean
    Dim ds As New DataSet
    Dim i As Integer
    Dim str As String = "select wiplocation from cpi_wip_location where plant='" & plant & "' order by id asc"

    cmd.ConnOracle()
    ds = cmd.GetDataSet(str)
    cmd.CloseConn()

    If ds.Tables(0).Rows.Count > 0 Then
    For i = 0 To ds.Tables(0).Rows.Count - 1
    Me.drploc.Items.Add(ds.Tables(0).Rows(i).Item(0).ToString)
    Next
    End If

    End Sub

    第一个空间的联动事件:

    Protected Sub drpplant_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles drpplant.SelectedIndexChanged
    Me.drploc.Items.Clear()
    Call downlocation(Me.drpplant.SelectedValue.ToString.Trim)
    End Sub

  • 相关阅读:
    [WordPress]配置Wordpress
    [磁盘数据分析] 实现解析特定分区体系(DOS分区体系)的主引导记录扇区
    [FZOJ2150]Fire Game 技巧BFS
    [HDOJ1028]Ignatius and the Princess III (母函数)
    [POJ3281]Dining 最大流(建图奇葩)
    [POJ1273]Drainage Ditches 网络流(最大流)
    HDU 5416
    hdu 3853 概率dp
    POJ 3071 概率DP
    HDU 5000 2014 ACM/ICPC Asia Regional Anshan Online DP
  • 原文地址:https://www.cnblogs.com/kevinhome/p/2730397.html
Copyright © 2011-2022 走看看