Asp net dropdownlist selected value not updating

Rated 4.34/5 based on 518 customer reviews

Suppose that you have a View to enter Customer details such as Customer ID, Company Name, Contact Name and Country.The Country value is to be presented to the user as a Drop Down List so that he can pick one value from the list.

Let's see what the problem is, its cause and finally the little tweak that I mentioned earlier.Once you have conceptual model classes designed by above suggested convention, you can go ahead and add CRUD views using Entity Framework to get fully functional Drop Down List even in Edit/Update mode on the fly.In above code, I’m checking what the selected value was using LINQ query and then using that value inside Select List.This approach will be useful if you don’t want another database table to store list of subjects and to go simple.In above code, you can see I commented out Subject class and its Db Set and used a new Subject Enum to store the list of subjects.

Leave a Reply