0
我有一个GridView的页脚2 DropDownList框,我试图根据在第一个框中所做的选择更新另一个DropDownList框的值。在gridview页脚dropdownlist框
基本上有2个DDL。用户可以从任何一个中挑选,并且所选值的互补值显示在相对的框中。 (是的,所有互补值存在于对方框的列表中。)
这些框根据需要填充,但即使我处于SelectedIndexChanged事件中,我似乎无法找到控件。
每个DDL位于Gridview的唯一列中。
Protected Sub DropDownList1_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim DDL1 As String = TryCast(GridView1.FooterRow.FindControl("DropDownList1"), DropDownList).SelectedValue
Dim DDL2 As DropDownList = TryCast(GridView1.FooterRow.FindControl("DropDownList2"), DropDownList)
DDL2.SelectedValue = DDL1
End Sub
和相对盒....
Protected Sub DropDownList2_SelectedIndexChanged(sender As Object, e As EventArgs)
Dim DDL1 As DropDownList = TryCast(GridView1.FooterRow.FindControl("DropDownList1"), DropDownList)
Dim DDL2 As String = TryCast(GridView1.FooterRow.FindControl("DropDownList2"), DropDownList).SelectedValue
DDL1.SelectedValue = DDL2
End Sub
谢谢,丹尼斯。这看起来不错,让我插入并看看会发生什么。 – htm11h 2014-10-10 17:56:32
好吧,我在两个事件中的SelectedIndex都保持为零。我需要重新绑定吗?该行返回-1 DDL2.Items.IndexOf(DDL2.Items.FindByValue(SelectedValue))。我知道价值在列表中。我可以看到它,如果我选择反对下拉。两项活动都相同。 – htm11h 2014-10-10 17:59:32
好的,我转换为使用SelectedIndex,我知道它的工作原理。感谢您的帮助!!! – htm11h 2014-10-10 18:03:32