Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Not IsPostBack Then Dim source As New System.Collections.Generic.List(Of String) source.Add("-1") source.Add("1") source.Add("2") DropDownList1.DataSource = source DropDownList1.DataBind() DropDownList2.DataSource = source DropDownList2.DataBind() End If End Sub Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged If DropDownList1.SelectedValue = -1 Then DropDownList2.Enabled = False End If End Sub
source.Add("-1")
source.Add("1")
source.Add("2") DropDownList1.DataSource = source
DropDownList1.DataBind() DropDownList2.DataSource = source
DropDownList2.DataBind() End If End Sub Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
If DropDownList1.SelectedValue = -1 Then
DropDownList2.Enabled = False
End If
End Sub
然后在SelectedIndexChanged()事件里写用JS也可以
AutopostBack 已经设置为true
protected void ddlType_SelectedIndexChanged(object sender, EventArgs e)
{
if (this.ddlType.SelectedIndex == 2)
{
this.ddlMonth.Enabled = true;
}
else
{
this.ddlMonth.Enabled = false;
}
}
还有在2005中我怎么连下拉框中的选取的值也获不得,
string deptTypeID = this.ddlType.SelectedValue;
每次点添加按纽就重新加载,得到的值都是第一项