我在页面加载时有DropDownList
iniwhich它会将所有数据加载到其中,但是当用户想要更改显示的文本时,只需单击下拉列表并选择新文本。我的问题是如何制作它以便保存他们选择的新文本值?这就是我现在所拥有的:
Private Sub cboCure_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cboCure.SelectedIndexChanged
cboCure.AutoPostBack = True
Dim objXMLDoc As New System.Xml.XmlDocument
Dim objNodeList As System.Xml.XmlNodeList
Dim strXML As String = ""
Dim url As String = ""
MaterialStuff = New Message.Material
Dim code As String = cboCure.SelectedItem.Text
cboCure.Items.Clear()
If cboCure.Items.Count < 1 Then
strXML = Message.GetCureCodes
objXMLDoc.LoadXml(strXML)
objNodeList = objXMLDoc.GetElementsByTagName("Material_Cure")
cboCure.Items.Add("")
For Each childNode As System.Xml.XmlNode In objNodeList.Item(0).ChildNodes
cboCure.Items.Add(New System.Web.UI.WebControls.ListItem(childNode.SelectSingleNode("CureCodeLetter").InnerText,
childNode.SelectSingleNode("CureCode").InnerText))
Next
End If
cboCure.SelectedItem.Text = code
End Sub
我希望变量code
成为用户点击的新文本值,但我似乎无法正确显示它,它会一直显示为""
或最初显示的值当页面加载时。
编辑:
这是我的Page_Load
If Not Page.IsPostBack Then
...code
else
cboCure_SelectedIndexChanged(sender, e )
end if