默认情况下,第一项从选择更改的下拉列表中选择 [英] by default first item select fromthe dropdown on selection change

查看:74
本文介绍了默认情况下,第一项从选择更改的下拉列表中选择的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

亲爱的所有人,

我有两个下拉菜单,ddlproduct和ddlesnNo.

选择产品时,它可以正常工作,但在ddlesnNo的情况下,即使选择其他项目,也会选择第一项.
我已将autopostback的属性设置为true,并且正在使用更新面板.

还会为ddlesnNo触发异步触发器(降落)Selected_Index_changed

参见下面的代码

Dear All,

I have two dropdowns, ddlproduct and ddlesnNo.

When selecting product it works fine, but in the case of ddlesnNo, the first item is selected even when selecting other items.
I have set the property of autopostback is true and I''m using update panel.

Asynchronous trigger is also fired for ddlesnNo (Dropdown) Selected_Index_changed

See the below code

protected void ddlESNList_SelectedIndexChanged(object sender, EventArgs e)
    {

if (ddlESNList.SelectedItem.Value != "")
        {
            // fill product in dropdownlist
            ProductEntiry productObj = new ProductEntiry();
            BALProduct bproductObj = new BALProduct();
            productObj.Productid = 0;
            productObj.Productname = ddlProductName.SelectedItem.Text;
            productObj.Mrp = 0.0;
            productObj.Description = null;
            productObj.Status = "A";
            DataTable dtb = bproductObj.FillProductBAL(productObj);
            if (dtb.Rows.Count > 0)
            {
                txtMrp.Text = Convert.ToString(dtb.Rows[0]["P_MRP"]);
                txtRatePcs.Text = Convert.ToString(dtb.Rows[0]["P_Sales"]);
                //ddlESNList.Items.RemoveAt(ddlESNList.SelectedIndex);
            }
            else
            {
                txtMrp.Text = "";
                txtRatePcs.Text = "";

                //Message Display
                string msg = "<script type=''text/javascript''>";
                msg += " alert(''No Item Data Found!!'')";
                msg += "</script>";
                ClientScript.RegisterClientScriptBlock(typeof(Page), "message", msg);
            }
        }
        else
        {
            //Message Display
            string msg = "<script type=''text/javascript''>";
            msg += " alert(''Select Product from the list!!'')";
            msg += "           ClientScript.RegisterClientScriptBlock(typeof(Page), "message", msg);
        }
}

推荐答案

,但在ddlesnNo的情况下,即使选择其他项,也会选择第一项.
听起来您在回发期间正在重新填充下拉列表.看看,如果您错过了使用IsPostback页面属性以避免在回发时重新加载下拉项的问题.
but in the case of ddlesnNo, the first item is selected even when selecting other items.
Sounds like you are re-populating the dropdown during the postback. See, if you have missed using IsPostback page property to avoid reload of dropdown items on postback.


这篇关于默认情况下,第一项从选择更改的下拉列表中选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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