both dropdownlist changes?

inkedGFX

Well-known member
Joined
Feb 2, 2013
Messages
142
Programming Experience
Beginner
I have 2 dropdownlist boxes on a Asp web page , they are both bound to a database , each one to a different table. I am using linq to sql to get the info from the table and display the results some text boxes.....the problem is when I select one Item from a dropdown ..it seems to get the info from both tables in the database...I have the code below for each of the dropdown list boxes....the code is in the selected index change event for both dropdown boxes

this is for the dropdown for the customers
using (DB_ClassDataContext myDB = new DB_ClassDataContext(conn))
            {
                var cust = from c in myDB.Customers
                           where c.Company_Name == DropDownList3.Text
                           select new
                           {
                               customer = c.Company_Name,
                               contact = c.Contact_Name,
                               phone = c.Bus_Phone,
                               address = c.Address
                           };


                foreach (var item in cust)
                {
                    txtContactName.Text = item.contact;
                    txtPhone.Text = item.phone;
                    txtCompanyAddress.Text = item.address;
                }
            }


this is the dropdown for the Inventory Item Numbers

 using (DB_ClassDataContext Inv = new DB_ClassDataContext(conn))
            {
                var inventory = from inv in Inv.Inventories
                                where inv.ItemNumber == DropDownList2.Text
                                select new
                                {
                                    itemName = inv.ItemName,
                                    itemDesc = inv.ItemDesc,
                                    itemPrice = inv.ItemPrice
                                };


                foreach (var item in inventory)
                {
                    txtItemName.Text = item.itemName;
                    txtItemDesc.Text = item.itemDesc;
                    txtItemPrice.Text = item.itemPrice.ToString();
                }
            }


Thank you for any help

-InkedGFX
 
That's weird, I'm sure I had UpdateMode=Always when testing with DDL inside UpdatePanel. Perhaps it is because you also have added a trigger for this? A regular postback from DDL (AutoPostBack) inside UpdatePanel should cause update without adding a trigger. When I mentioned this in post 11 it was with a DDL triggering a different UpdatePanel than its own.
 
I have the trigger set for the selected index changed ....not sure if I need a trigger or not..but its working now!

thanks for all your help!

-InkedGFX
 
Back
Top Bottom