DropDownList 有一个奇怪的行为
aspx:
<asp:DropDownList runat="server" ID="ddlTimeZone" DataSource ="<%# TimeZoneInfo.GetSystemTimeZones().ToDictionary(z => z.DisplayName)%>" DataTextField="Key" DataValueField="Value">`
html:
<select name="ctl00$MainContent$ddlTimeZone" id="MainContent_ddlTimeZone">
<option value="(UTC-12:00) International Date Line West">(UTC-12:00) International Date Line West</option>
<option value="(UTC-11:00) Midway Island, Samoa">(UTC-11:00) Midway Island, Samoa</option>
<option value="(UTC-10:00) Hawaii">(UTC-10:00) Hawaii</option>
<option value="(UTC-09:00) Alaska">(UTC-09:00) Alaska</option>
<option value="(UTC-08:00) Pacific Time (US & Canada)">(UTC-08:00) Pacific Time (US & Canada)</option>
<option value="(UTC-08:00) Tijuana, Baja California">(UTC-08:00) Tijuana, Baja California</option>
<option value="(UTC-07:00) Arizona">(UTC-07:00) Arizona</option>
<option value="(UTC-07:00) Chihuahua, La Paz, Mazatlan">(UTC-07:00) Chihuahua, La Paz, Mazatlan</option>
当我尝试获取 ddlTimeZone.SelectedValue 时,我总是得到 null(或 -1,我不记得了),并且 SelectedItem 始终等于 null。
The aspx:
<asp:DropDownList runat="server" ID="ddlTimeZone" DataSource ="<%# TimeZoneInfo.GetSystemTimeZones().ToDictionary(z => z.DisplayName)%>" DataTextField="Key" DataValueField="Value">`
The html:
<select name="ctl00$MainContent$ddlTimeZone" id="MainContent_ddlTimeZone">
<option value="(UTC-12:00) International Date Line West">(UTC-12:00) International Date Line West</option>
<option value="(UTC-11:00) Midway Island, Samoa">(UTC-11:00) Midway Island, Samoa</option>
<option value="(UTC-10:00) Hawaii">(UTC-10:00) Hawaii</option>
<option value="(UTC-09:00) Alaska">(UTC-09:00) Alaska</option>
<option value="(UTC-08:00) Pacific Time (US & Canada)">(UTC-08:00) Pacific Time (US & Canada)</option>
<option value="(UTC-08:00) Tijuana, Baja California">(UTC-08:00) Tijuana, Baja California</option>
<option value="(UTC-07:00) Arizona">(UTC-07:00) Arizona</option>
<option value="(UTC-07:00) Chihuahua, La Paz, Mazatlan">(UTC-07:00) Chihuahua, La Paz, Mazatlan</option>
When I try to get the ddlTimeZone.SelectedValue I always get null (or -1, I don't remember) and the SelectedItem always equals null.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我明白了。一直以来都是
I've understoond. It is all along of