Dropdownlist data binding inside detailsview in asp.net
<p>I have detailsview that will be used to edit customer records. Inside this detailsview, I have a dropdownlist that shows list of countries.</p>

<p>I have a table called CountryList that will populate list of countries to the above dropdownlist.</p>

<p>User can edit and save data without any issue.</p>

<p>But, assume that customer record has the country selected as "Australia" and if I delete Australia from the CountryList and try to edit the customer inside the details view, I am getting below error.</p>

<pre><code>SelectedValue which is invalid because it does not exist in the list of items
</code></pre>

<p>I know the reason because the </p>

<pre><code>SelectedValue='&lt;%# Bind("Country") %&gt;' 
</code></pre>

<p>and it can't find it in the list.</p>

<p>So my question is, how to overcome this issue  ? </p>

<p>After searching the web, I found that I can override the Databind but I am not sure how to do this. Have no idea how to override and can someone please give me sample code ? </p>

<p>Also is there any other solution for this such as validate it before set ? </p>

<p>Thank you.</p>
