现在只知道如何获取DropDownList的内容添加到数据表中,但不知如何将内容反过来体现在DropDownList上
比如:
页面包括1个DropDownList,1个TEXTBOX,1个BUTTON,
DropDownList包括“北京”“上海”“天津”,
我现在在TEXTBOX中输入“北京”,如何实现点BUTTON后,DropDownList的“北京”项就被选中?用DropDownList哪个属性接收TEXTBOX的文本?
比如:
页面包括1个DropDownList,1个TEXTBOX,1个BUTTON,
DropDownList包括“北京”“上海”“天津”,
我现在在TEXTBOX中输入“北京”,如何实现点BUTTON后,DropDownList的“北京”项就被选中?用DropDownList哪个属性接收TEXTBOX的文本?
public static void DillDrownDrplistBind(ref DrowDrpList drplist,string DataFiledText,string DataFiledValue, bool IsBool)
{
if(IsBool==true)
{
drplist.items.add("=====");
}
ListItem LItem=new ListItem(DataFiledText,DataFiledVaue)
drpList.Items.add(LItem); //*****选择才添加的数据
drpList.SelectValue=DataFiledValue;
}
//*****调用接口就可以了
For i = 0 To myDrop.Items.Count - 1 '置控件的当前值
If Trim(myDrop.Items(i).Text = Trim(TEXTBOX1.text) Then
myDrop.SelectedIndex = i
exit for
End If
Next i
dropDownList.SelectedValue=textbox1.Text;
这个控件经常会出麻烦:1. 在 if(!IsPostBack) 中绑上数据2. dropDownList.AutoPostBack=true 放在 Page_Load 中