You could attach a method to the SelectedIndexChanged event on each child dropdown, either in the markup, either using a AddHandler in the RowDataBound event of your gridview
<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" />
Save the value wherever you want (hidden or textbox) when the selected item is changed
protected void ddlSelectedIndexChanged(object sender, System.EventArgs e)
{
DropDownList ddl = (DropDownList)sender;
txt1.Text = ddl.SelectedValue;
}
And use this value when clicking the button
private void btn1_Click(object sender, EventArgs e)
{
Response.Redirect("mypage.aspx?q=" + txt1.Text);
}
or use jquery onChange event atttached to the dropdowns ?
$('select').on('change', function() {
alert( this.value );
})
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.