下拉列表事件不触发?为什么 [英] dropdown list event is not firing ? why

查看:72
本文介绍了下拉列表事件不触发?为什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道吗?


下拉列表事件不触发?为什么
编码:

Can Anyone know?


dropdown list event is not firing ? why
coding:

protected void ddlplace_SelectedIndexChanged(object sender, EventArgs e)
    {

        if (ddlplace.SelectedIndex > 0)
        {
            float delivervalue, tax, shipping;
            string deliveryarea = ddlplace.SelectedItem.Value.ToString();
            delivervalue = dal.getdelivervalue(deliveryarea);
            lbldp.Text = delivervalue.ToString();
            tax = dal.gettax(deliveryarea);
            lbltax.Text = tax.ToString();
            shipping = dal.getshipping(deliveryarea);
            lblship.Text = shipping.ToString();
        }

    }

推荐答案

其他几种情况(Autopostback=True除外)

ASP.NET:错误:DropDownList OnSelectedIndexChanged事件未触发 [在页面加载时检测DropDownList SelectedIndexChanged [
Here other couple of cases(other than Autopostback=True)

ASP.NET: Error: DropDownList OnSelectedIndexChanged Event Not Firing[^]
also check this
Detect DropDownList SelectedIndexChanged on Page Load[^]


将autopostback属性设置为true
set autopostback property to true of dropdown list.


首先在aspx中检查是否具有OnSelectedIndexChanged以及是否设置了autopostback = true

如:
first check in aspx whether you are having OnSelectedIndexChanged or not and whether you set autopostback=true

as:
<asp:DropDownList ID="ddlCity" runat="server" CssClass="dropdownlist" OnSelectedIndexChanged="ddlCity_SelectedIndexChanged"

                                                                            AutoPostBack="true">
                                                                            <asp:ListItem Value="0">--select--



或确保下拉绑定代码位于if(!Page.IsPostBack)块中



or make sure that dropdown binding code is in if(!Page.IsPostBack) block


这篇关于下拉列表事件不触发?为什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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