DropDownList
Asp.netで発生している奇妙な動作
私のコード:
<asp:DropDownList ID="DDLFromMinutes" runat="server" Width="20%">
<asp:ListItem Text="00" Value="00"></asp:ListItem>
<asp:ListItem Text="15" Value="15"></asp:ListItem>
<asp:ListItem Text="30" Value="30"></asp:ListItem>
<asp:ListItem Text="45" Value="45"></asp:ListItem>
</asp:DropDownList>
ただし、たとえば、選択した値が 15 の場合に実行すると、2 回取得されますDropDownList
FireBug でのデバッグ中に、以下を取得します。
<select id="ContentPlaceHolder1_DDLFromMinutes" style="width:20%;" name="ctl00$ContentPlaceHolder1$DDLFromMinutes">
<option value="00" selected="selected">30</option>
<option value="15">15</option>
<option value="30">30</option>
<option value="45">45</option>
</select>
コードビハインド:
string Frominput = seprateFromTime[1];
string Frommin = Frominput.Substring(0, 2);
DDLFromMinutes.SelectedItem.Text = Frommin;
if (DDLFromMinutes.Items.Count > 0)
{
DDLFromMinutes.SelectedIndex = DDLFromMinutes.Items.IndexOf(DDLFromMinutes.Items.FindByText(Frommin));
}
データの保存中に使用されますDDLFromMinutes.SelectedItem.Text
が、これは問題になる可能性がありますか?