onSelectIndexChanged
イベントを担当しています。DropDownList の選択が変更されると、イベントが発生します。問題は、DropDownList がまだ と の古い値を返すことSelectedValue
ですSelectedIndex
。私は何を間違っていますか?
aspx ファイルの DropDownList 定義は次のとおりです。
<div style="margin: 0px; padding: 0px 1em 0px 0px;">
<span style="margin: 0px; padding: 0px; vertical-align: top;">Route:</span>
<asp:DropDownList id="Select1" runat="server" onselectedindexchanged="index_changed" AutoPostBack="true">
</asp:DropDownList>
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</div>
DropDownListOnSelectedIndexChanged
イベント ハンドラは次のとおりです。
protected void index_changed(object sender, EventArgs e)
{
decimal d = Convert.ToDecimal( Select1.SelectedValue );
Literal1.Text = d.ToString();
}