比如在a.aspx中有已绑定了的DropDownList控件
请问如何定义它初始选定的值?比如先选择了“北京市”,当点击提交后,网页链接到了a.aspx?key=1,DropDownList的选定值就是“北京市”,而不是“请选择城市”
请问如何定义它初始选定的值?比如先选择了“北京市”,当点击提交后,网页链接到了a.aspx?key=1,DropDownList的选定值就是“北京市”,而不是“请选择城市”
调试欢乐多
Dim i As Integer
For i = 0 To CInt(Thedrop.Items.Count - 1)
If Thedrop.Items(i).Text = str Then
Thedrop.SelectedIndex = i
End If
Next
End Function给你这个,偶一直在用的!!
把ID作为DropDownList的ValueMember的话yourDropDownList.Items.FindByValue( "1" ).Selected = true;
Getdrop(你的dropdownlist,"北京市")
{
if (DropDownlist.Items(i).Text == name )//name 为你前端传来的值“北京”
{
DropDownlist.SelectedIndex = i;
}
}