下拉列表的HTML代码是
<div style="float: left; width: 100%; margin-top: 5px;">
<div style="float: left; width: 42%;">
<span class="Red_Bold_70">* </span>
<asp:Label ID="lblStateTitle" runat="Server" Text="State/Province: " CssClass="NoColor_Bold_70"></asp:Label>
</div>
<div style="float: left; width: 54%; padding-left: 4px;">
<asp:DropDownList ID="ddlState" runat="server" CssClass="NoColor__70">
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvStateDDL" runat="server" ErrorMessage="* State is required" ControlToValidate="ddlState" CssClass="Red__70" Display="Dynamic" InitialValue="0"></asp:RequiredFieldValidator>
<asp:TextBox ID="txtState" runat="server" CssClass="NoColor__70" Width="50%" Text=""></asp:TextBox>
<asp:RequiredFieldValidator ID="rfvStateTextBox" runat="server" ErrorMessage="* State is required" ControlToValidate="txtState" CssClass="Red__70" Display="Dynamic" InitialValue="0"></asp:RequiredFieldValidator>
</div>
</div>
代码背后:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
PopulateCountryDDL()
PopulateStateDDL()
end if
end sub
populateStateDDL从数据源中恢复状态。
Protected Sub ddlState_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ddlState.SelectedIndexChanged
selectedState = ddlState.SelectedValue.ToString()
End Sub
当我检查ddlstate所选项目的值时,我看到了一个随机值而不是select.owever,但它适用于少数几个选项,并且经常不是很少。你可以在这里建议可能是什么问题?