Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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);
        }
}
Posted
Updated 11-Jun-11 1:34am
v3
Comments
parmar_punit 11-Jun-11 6:26am    
plz put your all code to clear the question.
Dalek Dave 11-Jun-11 7:35am    
Edited for Grammar, Spelling and Readability.
[no name] 11-Jun-11 9:08am    
Is there a question here? Perhaps I missed it.

1 solution

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.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900