ASP.Net的DropDownList OnSelectedIndexChange不点火 [英] ASP.Net DropDownList OnSelectedIndexChange not firing

查看:797
本文介绍了ASP.Net的DropDownList OnSelectedIndexChange不点火的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有以下DropDownList控件:

I have the following DropDownList control:

<asp:label runat="server" text="Filter by state: "></asp:label>
<asp:dropdownlist runat="server" id="filterbystate" 
    OnSelectedIndexChanged="FilterByState">
    <asp:ListItem value="all" selected="True">All</asp:ListItem>
    <asp:ListItem value="ca" selected="False">California</asp:ListItem>
    <asp:ListItem value="co" selected="False">Colorado</asp:ListItem>
    <asp:ListItem value="id" selected="False">Idaho</asp:ListItem>
    <asp:ListItem value="ut" selected="False">Utah</asp:ListItem>
</asp:dropdownlist>

下面是方法:

protected void FilterByState(object sender, EventArgs e)
{
    var value = e;
}

该方法不会触发出于某种原因。我选择一个不同的值,并没有任何反应。我所试图做的是重新载入页面传入状态值,所以我可以用它来过滤结果。

The method will not fire for some reason. I select a different value and nothing happens. What I am trying to do is reload the page passing in the state value so I can filter the results by it.

我在做什么错了?

推荐答案

设置的AutoPostBack =真为您的DDL的一个属性,它会自动发送回选定的指数变化事件

Set AutoPostBack=True as an attribute of your DDL and it will automatically post back the selected index change event

这篇关于ASP.Net的DropDownList OnSelectedIndexChange不点火的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆