你可以附加一個方法SelectedIndexChanged事件上的每個孩子下拉列表中,無論是在標記,或者使用在的AddHandler GridData的RowDataBound事件
<asp:GridView ID="gv1" runat="server">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="ddl" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlSelectedIndexChanged">
<asp:ListItem Value="1"></asp:ListItem>
<asp:ListItem Value="2"></asp:ListItem>
<asp:ListItem Value="3"></asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
<asp:TextBox ID="txt1" runat="server" />
<asp:Button ID="btn1" runat="server" Text="redirect" />
保存任何你想要的值(隱藏或文本框)時,所選擇的項目更改
protected void ddlSelectedIndexChanged(object sender, System.EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
txt1.Text = ddl.SelectedValue;
}
,點擊按鈕
private void btn1_Click(object sender, EventArgs e)
{
Response.Redirect("mypage.aspx?q=" + txt1.Text);
}
時使用此值或使用atttached在下拉菜單的jQuery onChange事件?
$('select').on('change', function() {
alert(this.value);
})
謝謝你幫助我很多 –