Asp net dropdownlist selected value not updating

02-Jun-2016 19:54

The problem was resolved by slightly tweaking the code but since it sounded like a tricky thing that many beginners would stumble upon I am writing this post.Let's see what the problem is, its cause and finally the little tweak that I mentioned earlier.This article provides a comprehensive solution for defining an edit template in a Form View. The Form View is a binding control like the Grid View, except where the Grid View shows multiple rows of data and the Form View shows one record at a time in a form layout.The edit template contains a Drop Down List and the population, binding, and updating is all handled declaratively. After you complete the data source wizard the Form View will have controls added to it for the Item Template, Edit Item Template, and Insert Item Template.Now you can ask questions directly to me on my new site ASPForums. I have been asked this question many times that ‘how to populate/activate selected value/item (which I selected while inserting/adding new record) in Edit/Update mode’. Please maintain the naming convention (like I used ‘Student Id’) so that by looking at the conceptual model EF generates the right view (with working Drop Down List) for you and populates it with right data (subjects).

The Edit Item Template will contain Text Box controls by default.

Solution: The solution to this issue lies within the name of the drop down list.

Changing the name to not match the model’s property name will correctly render the drop down with the selected value.

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.

The Edit Item Template will contain Text Box controls by default.

Solution: The solution to this issue lies within the name of the drop down list.

Changing the name to not match the model’s property name will correctly render the drop down with the selected value.

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.

You can use the Smart tags menu or switch to the ASP.