使用VB.NET CODE获取下拉列表的选定值 [英] Get the selected value of dropdownlist using VB.NET CODE
本文介绍了使用VB.NET CODE获取下拉列表的选定值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Hello Dears,
i有 2 DropDownList(ddl_List1,ddl_List2)
i将填充来自数据库(SQL SERVER)的ddl_List1 和i ' m已经完成
第二个列表ddl_List2应该从数据库填充如下:
Dim dr As System.Data.SqlClient.SqlDataReader
Dim RelatedDeptEmpListItem As New ListItem
RelatedDeptEmpListItem.Value = -1
RelatedDeptEmpListItem.Text =
ddl_List2 Items.Add((RelatedDeptEmpListItem))
Dim RelatedDeptEmpListCounter As Integer = 0
dr = UsersInSignature.GetUsersInSignatures(ddl_List1.SelectedValue)
while dr.Read
Dim UserInfo As New ListItem
UserInfo.Value = dr(UserID )
UserInfo.Text = dr(UserFullName)
ddl_List2.Items.Add((UserInfo))
RelatedDeptEmpListCounter = RelatedDeptEmpListCounter + 1
End
dr这个代码块中的.Close()
填充的第二个列表取决于第一个列表的选定值。
问题是:
当我点击保存按钮时,第二个列表的选定值丢失,第二个列表再次重新加载$ b
$ b所以,我该如何解决这个问题,并获得第二个List的所选值
任何想法请
谢谢
我尝试了什么:
i尝试了不是ispostback和我试图在负载级别中获取所选值
但没有任何帮助我
解决方案
将其设置为true,它应该可以解决问题。
Hello Dears ,
i have 2 DropDownList ( ddl_List1 , ddl_List2 )
i will populate ddl_List1 from database (SQL SERVER) and i'm already done
the second list ddl_List2 should filled from database as the following :
Dim dr As System.Data.SqlClient.SqlDataReader
Dim RelatedDeptEmpListItem As New ListItem
RelatedDeptEmpListItem.Value = -1
RelatedDeptEmpListItem.Text = ""
ddl_List2 Items.Add((RelatedDeptEmpListItem))
Dim RelatedDeptEmpListCounter As Integer = 0
dr = UsersInSignature.GetUsersInSignatures(ddl_List1.SelectedValue)
While dr.Read
Dim UserInfo As New ListItem
UserInfo.Value = dr("UserID")
UserInfo.Text = dr("UserFullName")
ddl_List2.Items.Add((UserInfo))
RelatedDeptEmpListCounter = RelatedDeptEmpListCounter + 1
End While
dr.Close()
in this block of code the second list populated depends on the selected value of the first list .
THE PROBLEM IS :
when i click on save button the selected value of the second list LOST and the second list reloaded again
so , how can i fix this problem and get the selected value of the second List
any idea please
thanks
What I have tried:
i tried the not ispostback and i tried to get the selected value in the load level
but nothing help me
解决方案
Set it to true, it should solve the problem.
这篇关于使用VB.NET CODE获取下拉列表的选定值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文