title: Formview insert not working if autopostback=true. asp.net
body: <p>I have a page with a <code>dropdownlist</code> that has a <code>selectedIndexChanged</code> event attached.  So, for each option in the <code>dropdownlist</code>, there is a <code>usercontrol</code> that contains a form relevant to that section.  (each user control is in a panel, and the <code>selectedIndexChanged</code> event toggles visibility of that panel.</p>
  
  <p>However, for one of the forms, I am inserting the data into SQL Server, so have used a formview, only the trouble was it wasn't inserting.</p>
  
  <p>After spending ages stripping back the page to find out the point of failure, it turns out that it is the <code>AutoPostBack="true</code>" on the <code>dropdownlist</code> that is causing the problem.  Even when I remove all other panels/usercontrols, and making it so the formview panel is visible all the team (meaning that the <code>dropdownlist</code> is not changed and therefore no pastback happens) it still just fails.  If I remove that from the dropdown, the data inserts no problem.</p>
  
  <p>Has anyone seen this before, or can think of a logical reason why this might be happening?</p>
  
  <p>I'll post up the code of the <code>dropdown</code> just in case it helps:</p>
  
  <pre><code>&lt;asp:Label ID="uxFormSwitchLabel" runat="server" Text="What would you like to do?" AssociatedControlID="uxFormSwitch" /&gt;
  &lt;asp:DropDownList ID="uxFormSwitch" runat="server" AutoPostBack="true" OnSelectedIndexChanged="uxFormSwitch_SelectedIndexChanged"&gt;
     &lt;asp:ListItem Value="Please Select" Text="Please Select" Selected="True" /&gt;
     &lt;asp:ListItem Value="Change my address" Text="Change my address" /&gt;
     &lt;asp:ListItem Value="Change my bank details" Text="Change my bank details" /&gt;
     &lt;asp:ListItem Value="Change my class of use" Text="Change my class of use" /&gt;
     &lt;asp:ListItem Value="Change my personal details" Text="Change my personal details" /&gt;
     &lt;asp:ListItem Value="Other" Text="Other" /&gt;
  &lt;/asp:DropDownList&gt;
  </code></pre>
  
  <p>UPDATE - as requested, here is the code for the formview insert:</p>
  
  <pre><code>&lt;asp:FormView ID="uxDriverByID" runat="server" DataKeyNames="DriverID" DefaultMode="Insert" DataSourceID="dsDriverByID" ondatabound="uxDriverByID_DataBound" oniteminserting="uxDriverByID_ItemInserting"&gt;    
      &lt;InsertItemTemplate&gt;
          &lt;asp:HiddenField ID="uxEntryType" runat="server" Value='&lt;%# Bind("EntryType") %&gt;' /&gt;
  
          &lt;asp:Label ID="uxDateLabel" runat="server" AssociatedControlID="uxDate" Text="Date cover is to begin"&gt;&lt;/asp:Label&gt;
          &lt;asp:TextBox ID="uxDate" CssClass="datepicker" runat="server" Text='&lt;%# Bind("StartDate") %&gt;'&gt;&lt;/asp:TextBox&gt;        
      &lt;div class="clear"&gt;&lt;/div&gt;        
  
  
          &lt;asp:Label ID="uxEndDateLabel" runat="server" AssociatedControlID="uxEndDate" Text="Date cover is to begin"&gt;&lt;/asp:Label&gt;
          &lt;asp:TextBox ID="uxEndDate" CssClass="datepicker" runat="server" Text='&lt;%# Bind("EndDate") %&gt;'&gt;&lt;/asp:TextBox&gt;
  
          &lt;asp:Label ID="uxTitleLabel" runat="server" AssociatedControlID="uxTitle" Text="Title" &gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="uxTitle" runat="server" SelectedValue='&lt;%# Bind("Title") %&gt;'&gt;
                  &lt;asp:ListItem Value="0" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="1" Text="Mr" /&gt;
                  &lt;asp:ListItem Value="2" Text="Mrs" /&gt;
                  &lt;asp:ListItem Value="3" Text="Miss" /&gt;
                  &lt;asp:ListItem Value="4" Text="Ms" /&gt;
                  &lt;asp:ListItem Value="5" Text="Doctor" /&gt;
              &lt;/asp:DropDownList&gt;
  
      &lt;asp:Label ID="uxFirstNameLabel" runat="server" AssociatedControlID="uxFirstName" Text="First Name"&gt;&lt;/asp:Label&gt;
          &lt;asp:TextBox ID="uxFirstName" runat="server" Text='&lt;%# Bind("FirstName") %&gt;'&gt;&lt;/asp:TextBox&gt;
  
          &lt;asp:Label ID="uxSurnameLabel" runat="server" AssociatedControlID="uxSurname" Text="Surname"&gt;&lt;/asp:Label&gt;
          &lt;asp:TextBox ID="uxSurname" runat="server" Text='&lt;%# Bind("Surname") %&gt;'&gt;&lt;/asp:TextBox&gt;
  
          &lt;asp:Label ID="uxDateOfBirthLabel" runat="server" AssociatedControlID="uxDay" Text="Date of birth"&gt;&lt;/asp:Label&gt;
          &lt;div class="input"&gt;
              &lt;div class="dateofbirth"&gt;
                  &lt;asp:DropDownList ID="uxDay" runat="server"&gt;
                  &lt;/asp:DropDownList&gt;
                  &lt;asp:DropDownList ID="uxMonth" runat="server"&gt;
                  &lt;/asp:DropDownList&gt;
                  &lt;asp:DropDownList ID="uxYear" runat="server"&gt;
                  &lt;/asp:DropDownList&gt;
              &lt;/div&gt;
          &lt;/div&gt;
  
          &lt;asp:Label ID="uxGenderLabel" runat="server" AssociatedControlID="uxGender" Text="Gender"&gt;&lt;/asp:Label&gt;
          &lt;div class="input"&gt;
          &lt;asp:DropDownList ID="uxGender" runat="server" SelectedValue='&lt;%# Bind("Gender") %&gt;'&gt;
              &lt;asp:ListItem Value="0" Text="Please Select" /&gt;
              &lt;asp:ListItem Value="1" Text="Male" /&gt;
              &lt;asp:ListItem Value="2" Text="Female" /&gt;
          &lt;/asp:DropDownList&gt;  
  
          &lt;asp:Label ID="uxRelationshipLabel" runat="server" AssociatedControlID="uxRelationship"
              Text="Relationship to Proposer"&gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="uxRelationship" runat="server" SelectedValue='&lt;%# Bind("Relationship") %&gt;'&gt;
                  &lt;asp:ListItem Value="Please Select" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="Spouse" Text="Spouse" /&gt;
                  &lt;asp:ListItem Value="Common law partner" Text="Common law partner" /&gt;
                  &lt;asp:ListItem Value="Leasing company" Text="Leasing company" /&gt;
                  &lt;asp:ListItem Value="Parent" Text="Parent" /&gt;
                  &lt;asp:ListItem Value="Company" Text="Company" /&gt;
                  &lt;asp:ListItem Value="Other" Text="Other" /&gt;
              &lt;/asp:DropDownList&gt;
          &lt;div class="clear"&gt;&lt;/div&gt;                
  
          &lt;asp:Label ID="uxMaritalStatusLabel" runat="server" AssociatedControlID="uxMaritalStatus" Text="Marital Status"&gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="uxMaritalStatus" runat="server" SelectedValue='&lt;%# Bind("MaritalStatus") %&gt;'&gt;
                  &lt;asp:ListItem Value="Please Select" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="Married" Text="Married" /&gt;
                  &lt;asp:ListItem Value="Single" Text="Single" /&gt;
                  &lt;asp:ListItem Value="Divorced" Text="Divorced" /&gt;
                  &lt;asp:ListItem Value="Widowed" Text="Widowed" /&gt;
                  &lt;asp:ListItem Value="Separated" Text="Separated" /&gt;
                  &lt;asp:ListItem Value="Common Law" Text="Common Law" /&gt;
                  &lt;asp:ListItem Value="Civil Partner" Text="Civil Partner" /&gt;
              &lt;/asp:DropDownList&gt;
  
          &lt;asp:Label ID="uxEmploymentStatusLabel" AssociatedControlID="uxEmploymentStatus" runat="server" Text="Employment Status"/&gt;
          &lt;asp:DropDownList ID="uxEmploymentStatus" runat="server" SelectedValue='&lt;%# Bind("EmploymentStatus") %&gt;'&gt;
              &lt;asp:ListItem Value="0" Text="Please Select" /&gt;
              &lt;asp:ListItem Value="1" Text="Employed" /&gt;
              &lt;asp:ListItem Value="2" Text="Self Employed" /&gt;
              &lt;asp:ListItem Value="3" Text="Retired" /&gt;
              &lt;asp:ListItem Value="4" Text="Household Duties" /&gt;
              &lt;asp:ListItem Value="5" Text="In Full or Part-time education" /&gt;
              &lt;asp:ListItem Value="6" Text="Unemployed" /&gt;
              &lt;asp:ListItem Value="7" Text="Company" /&gt;
              &lt;asp:ListItem Value="8" Text="Independent Means" /&gt;
              &lt;asp:ListItem Value="9" Text="Voluntary Work" /&gt;
          &lt;/asp:DropDownList&gt; 
  
              &lt;asp:Label ID="uxOccupationLabel" AssociatedControlID="uxOccupation" runat="server" Text="Occupation" /&gt;  
              &lt;asp:TextBox ID="uxOccupation" runat="server" Text='&lt;%# Bind("Occupation") %&gt;'  /&gt;  
  
              &lt;asp:Label ID="uxBusinessLabel" AssociatedControlID="uxBusiness" runat="server" Text="Employer's business" /&gt;  
              &lt;asp:TextBox ID="uxBusiness" runat="server" Text='&lt;%# Bind("Business") %&gt;' /&gt;
  
  
              &lt;asp:Label ID="uxSecondaryEmploymentLabel" runat="server" AssociatedControlID="uxSecondaryEmployment" Text="Does this driver have a second occupation?"&gt;&lt;/asp:Label&gt;
               &lt;asp:DropDownList ID="uxSecondaryEmployment" runat="server"&gt;
                  &lt;asp:ListItem Value="" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="No" Text="No" /&gt;
                  &lt;asp:ListItem Value="Yes" Text="Yes" /&gt;
              &lt;/asp:DropDownList&gt;
  
              &lt;asp:Label ID="uxSecondaryEmploymentStatusLabel" AssociatedControlID="uxSecondaryEmploymentStatus" runat="server" Text="Secondary Employment Status" /&gt;
              &lt;asp:DropDownList ID="uxSecondaryEmploymentStatus" runat="server" SelectedValue='&lt;%# Bind("SecondaryEmploymentStatus") %&gt;'&gt;
                  &lt;asp:ListItem Value="0" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="1" Text="Employed" /&gt;
                  &lt;asp:ListItem Value="2" Text="Self Employed" /&gt;
                  &lt;asp:ListItem Value="3" Text="Retired" /&gt;
                  &lt;asp:ListItem Value="4" Text="Household Duties" /&gt;
                  &lt;asp:ListItem Value="5" Text="In Full or Part-time education" /&gt;
                  &lt;asp:ListItem Value="6" Text="Unemployed" /&gt;
                  &lt;asp:ListItem Value="7" Text="Company" /&gt;
                  &lt;asp:ListItem Value="8" Text="Independent Means" /&gt;
                  &lt;asp:ListItem Value="9" Text="Voluntary Work" /&gt;
              &lt;/asp:DropDownList&gt;
  
              &lt;asp:Label ID="uxSecondaryOccupationLabel" AssociatedControlID="uxSecondaryOccupation" runat="server" Text="Secondary occupation" /&gt;  
              &lt;asp:TextBox ID="uxSecondaryOccupation" runat="server" Text='&lt;%# Bind("SecondaryOccupation") %&gt;' /&gt;
  
              &lt;asp:Label ID="uxSecondaryBusinessLabel" AssociatedControlID="uxSecondaryBusiness" runat="server" Text="Employer's business" /&gt;  
              &lt;asp:TextBox ID="uxSecondaryBusiness" runat="server" Text='&lt;%# Bind("SecondaryBusiness") %&gt;' /&gt; 
  
          &lt;asp:Label ID="uxLicenceTypeLabel" runat="server" AssociatedControlID="uxLicenceType" Text="What type of licence does the driver hold?"&gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="uxLicenceType" runat="server" SelectedValue='&lt;%# Bind("LicenceType") %&gt;'&gt;
                  &lt;asp:ListItem Value="Please Select" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="Full(UK)" Text="Full(UK)" /&gt;
                  &lt;asp:ListItem Value="Provisional(UK)" Text="Provisional(UK)" /&gt;
                  &lt;asp:ListItem Value="Foreign" Text="Foreign" /&gt;
                  &lt;asp:ListItem Value="Restricted less than 3 years" Text="Restricted less than 3 years" /&gt;
                  &lt;asp:ListItem Value="Restricted 3 years or over" Text="Restricted 3 years or over" /&gt;
              &lt;/asp:DropDownList&gt;
  
          &lt;asp:Label ID="uxTimeHeldLabel" runat="server" AssociatedControlID="uxTimeHeld" Text="How many years has the driver held this licence?"&gt;&lt;/asp:Label&gt;
          &lt;asp:DropDownList ID="uxTimeHeld" runat="server" SelectedValue='&lt;%# Bind("TimeHeld") %&gt;'&gt;
              &lt;asp:ListItem Value="0" Text="0" /&gt;
              &lt;asp:ListItem Value="1" Text="1" /&gt;
              &lt;asp:ListItem Value="2" Text="2" /&gt;
              &lt;asp:ListItem Value="3" Text="3" /&gt;
              &lt;asp:ListItem Value="4" Text="4" /&gt;
              &lt;asp:ListItem Value="5" Text="5" /&gt;
              &lt;asp:ListItem Value="6" Text="6" /&gt;
              &lt;asp:ListItem Value="7" Text="7" /&gt;
              &lt;asp:ListItem Value="8" Text="8" /&gt;
              &lt;asp:ListItem Value="9" Text="9 or over" /&gt;
          &lt;/asp:DropDownList&gt;
  
          &lt;asp:Label ID="uxClassSelectLabel" runat="server" AssociatedControlID="uxClassSelect" Text="What class of use do you want to change to?"&gt;&lt;/asp:Label&gt;
          &lt;asp:DropDownList ID="uxClassSelect" runat="server" SelectedValue='&lt;%# Bind("ClassSelect") %&gt;'&gt;
              &lt;asp:ListItem Value="Please Select" Text="Please Select" /&gt;
              &lt;asp:ListItem Value="1" Text="SDP - Includes Commuting if Required" /&gt;
              &lt;asp:ListItem Value="2" Text="Business Use Policy Holder In Person" /&gt;
              &lt;asp:ListItem Value="3" Text="Business Use Spouse In Person" /&gt;
              &lt;asp:ListItem Value="4" Text="usiness Use Policy Holder and Spouse" /&gt;
              &lt;asp:ListItem Value="5" Text="Policy Holder Business - Authorised Drivers" /&gt;
              &lt;asp:ListItem Value="6" Text="Commercial Travelling" /&gt;
          &lt;/asp:DropDownList&gt;
  
          &lt;asp:Label ID="uxConvictionsLabel" runat="server" AssociatedControlID="uxConvictions" Text="Has this driver had any motoring convictions in the last 5 years?"&gt;&lt;/asp:Label&gt;
          &lt;asp:DropDownList ID="uxConvictions" runat="server" SelectedValue='&lt;%# Bind("Convictions") %&gt;'&gt;
              &lt;asp:ListItem Value="" Text="Please Select" /&gt;
              &lt;asp:ListItem Value="No" Text="No" /&gt;
              &lt;asp:ListItem Value="Yes" Text="Yes" /&gt;
          &lt;/asp:DropDownList&gt;
  
  
          &lt;asp:Label ID="uxClaimsLabel" runat="server" AssociatedControlID="uxClaims" Text="Has this driver had any motoring claims in the last 5 years?"&gt;&lt;/asp:Label&gt;
          &lt;div class="input"&gt;
          &lt;asp:DropDownList ID="uxClaims" runat="server" SelectedValue='&lt;%# Bind("Claims") %&gt;'&gt;
              &lt;asp:ListItem Value="" Text="Please Select" /&gt;
              &lt;asp:ListItem Value="No" Text="No" /&gt;
              &lt;asp:ListItem Value="Yes" Text="Yes" /&gt;
          &lt;/asp:DropDownList&gt;
  
  
          &lt;asp:Label ID="uxResidentLabel" runat="server" AssociatedControlID="uxResident" Text="How many years has this driver been a permanent UK resident?"&gt;&lt;/asp:Label&gt;
          &lt;asp:DropDownList ID="uxResident" runat="server" SelectedValue='&lt;%# Bind("Resident") %&gt;'&gt;
                  &lt;asp:ListItem Value="0" Text="0" /&gt;
                  &lt;asp:ListItem Value="1" Text="1" /&gt;
                  &lt;asp:ListItem Value="2" Text="2" /&gt;
                  &lt;asp:ListItem Value="3" Text="3" /&gt;
                  &lt;asp:ListItem Value="4" Text="4" /&gt;
                  &lt;asp:ListItem Value="5" Text="5" /&gt;
                  &lt;asp:ListItem Value="6" Text="6" /&gt;
                  &lt;asp:ListItem Value="7" Text="7" /&gt;
                  &lt;asp:ListItem Value="8" Text="8" /&gt;
                  &lt;asp:ListItem Value="9" Text="9 or over" /&gt;
              &lt;/asp:DropDownList&gt;
  
          &lt;asp:Label ID="uxHowOftenLabel" runat="server" AssociatedControlID="uxHowOften" Text="How often will this driver use the vehicle?"&gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="uxHowOften" runat="server" SelectedValue='&lt;%# Bind("HowOften") %&gt;'&gt;
                  &lt;asp:ListItem Value="" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="1" Text="Not Main User (frequent)" /&gt;
                  &lt;asp:ListItem Value="2" Text="Main User" /&gt;
                  &lt;asp:ListItem Value="3" Text="Infrequent (casual)" /&gt;
              &lt;/asp:DropDownList&gt;
  
          &lt;asp:Label ID="uxHomeownerLabel" runat="server" AssociatedControlID="uxHomeowner" Text="Is this driver a homeowner?"&gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="uxHomeowner" runat="server" SelectedValue='&lt;%# Bind("Homeowner") %&gt;'&gt;
                  &lt;asp:ListItem Value="" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="No" Text="No" /&gt;
                  &lt;asp:ListItem Value="Yes" Text="Yes" /&gt;
              &lt;/asp:DropDownList&gt;
  
          &lt;asp:Label ID="uxNumOfCarsLabel" runat="server" AssociatedControlID="uxNumOfCars" Text="Does this driver have access to any other cars within the household?" /&gt;
          &lt;asp:DropDownList ID="uxNumOfCars" runat="server" SelectedValue='&lt;%# Bind("NumOfCars") %&gt;'&gt;
              &lt;asp:ListItem Value="0" Text="0" /&gt;
              &lt;asp:ListItem Value="1" Text="1" /&gt;
              &lt;asp:ListItem Value="2" Text="2" /&gt;
              &lt;asp:ListItem Value="3" Text="3" /&gt;
              &lt;asp:ListItem Value="4" Text="4" /&gt;
              &lt;asp:ListItem Value="5" Text="5" /&gt;
              &lt;asp:ListItem Value="6" Text="6" /&gt;
              &lt;asp:ListItem Value="7" Text="7" /&gt;
              &lt;asp:ListItem Value="8" Text="8" /&gt;
              &lt;asp:ListItem Value="9" Text="9 or over" /&gt;
          &lt;/asp:DropDownList&gt;
          &lt;div class="clear"&gt;&lt;/div&gt;    
  
          &lt;asp:Label ID="uxCarsOwnedLabel" runat="server" AssociatedControlID="uxCarsOwned" Text="Does this driver own any other cars?" /&gt;
          &lt;asp:DropDownList ID="uxCarsOwned" runat="server" SelectedValue='&lt;%# Bind("CarsOwned") %&gt;'&gt;
              &lt;asp:ListItem Value="0" Text="0" /&gt;
              &lt;asp:ListItem Value="1" Text="1" /&gt;
              &lt;asp:ListItem Value="2" Text="2" /&gt;
              &lt;asp:ListItem Value="3" Text="3" /&gt;
              &lt;asp:ListItem Value="4" Text="4" /&gt;
              &lt;asp:ListItem Value="5" Text="5" /&gt;
              &lt;asp:ListItem Value="6" Text="6" /&gt;
              &lt;asp:ListItem Value="7" Text="7" /&gt;
              &lt;asp:ListItem Value="8" Text="8" /&gt;
              &lt;asp:ListItem Value="9" Text="9 or over" /&gt;
          &lt;/asp:DropDownList&gt;
          &lt;div class="clear"&gt;&lt;/div&gt;    
  
          &lt;asp:Label ID="uxClaimFreeLabel" runat="server" AssociatedControlID="uxClaimFree" Text="How many claim free years of driving other cars does this driver have" /&gt;
          &lt;asp:DropDownList ID="uxClaimFree" runat="server" SelectedValue='&lt;%# Bind("ClaimFree") %&gt;'&gt;
              &lt;asp:ListItem Value="0" Text="0" /&gt;
              &lt;asp:ListItem Value="1" Text="1" /&gt;
              &lt;asp:ListItem Value="2" Text="2" /&gt;
              &lt;asp:ListItem Value="3" Text="3" /&gt;
              &lt;asp:ListItem Value="4" Text="4" /&gt;
              &lt;asp:ListItem Value="5" Text="5" /&gt;
              &lt;asp:ListItem Value="6" Text="6" /&gt;
              &lt;asp:ListItem Value="7" Text="7" /&gt;
              &lt;asp:ListItem Value="8" Text="8" /&gt;
              &lt;asp:ListItem Value="9" Text="9 or over" /&gt;
          &lt;/asp:DropDownList&gt;
          &lt;div class="clear"&gt;&lt;/div&gt;  
  
          &lt;asp:Label ID="uxRefusedLabel" runat="server" AssociatedControlID="uxRefused" Text="Has this driver ever had insurance refused, cancelled, premiums increased, or conditions imposed?"&gt;&lt;/asp:Label&gt;
          &lt;asp:DropDownList ID="uxRefused" runat="server" SelectedValue='&lt;%# Bind("Refused") %&gt;'&gt;
                  &lt;asp:ListItem Value="" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="No" Text="No" /&gt;
                  &lt;asp:ListItem Value="Yes" Text="Yes" /&gt;
              &lt;/asp:DropDownList&gt;
  
          &lt;asp:Label ID="uxOtherConvictionsLabel" runat="server" AssociatedControlID="uxOtherConvictions" Text="Has this driver ever had any non-motoring criminal convictions or prosecutions pending?"&gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="uxOtherConvictions" runat="server" SelectedValue='&lt;%# Bind("OtherConvictions") %&gt;'&gt;
                  &lt;asp:ListItem Value="" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="No" Text="No" /&gt;
                  &lt;asp:ListItem Value="Yes" Text="Yes" /&gt;
              &lt;/asp:DropDownList&gt;
  
          &lt;asp:Label ID="uxDisabilityLabel" runat="server" AssociatedControlID="uxDisability" Text="Does this driver have any disability or medical condition that could affect their fitness to drive?"&gt;&lt;/asp:Label&gt;
              &lt;asp:DropDownList ID="uxDisability" runat="server" SelectedValue='&lt;%# Bind("Disability") %&gt;'&gt;
                  &lt;asp:ListItem Value="" Text="Please Select" /&gt;
                  &lt;asp:ListItem Value="No" Text="No" /&gt;
                  &lt;asp:ListItem Value="Yes" Text="Yes" /&gt;
              &lt;/asp:DropDownList&gt; 
  
          &lt;asp:Label ID="uxSubmitLabel" runat="server" AssociatedControlID="uxSubmit" Text="Submit"&gt;&lt;/asp:Label&gt;
          &lt;asp:LinkButton ID="uxSubmit" runat="server" style="float:left" Text="Submit"  CssClass="blue-button-ctrl med"
                  ValidationGroup="AddDriver" CausesValidation="true" CommandName="Insert" OnClick="uxSubmit_Click"  /&gt;
          &lt;asp:LinkButton ID="uxUpdateButton" style="float:left" Text="Save changes" 
              runat="server" CssClass="blue-button-ctrl" Visible="false"
              ValidationGroup="AddDriver" CausesValidation="true"  /&gt;
          &lt;div class="clear"&gt;&lt;/div&gt;   
  
      &lt;/InsertItemTemplate&gt;
  &lt;/asp:FormView&gt;
  
  &lt;asp:ObjectDataSource ID="dsDriverByID" runat="server" InsertMethod="DriverInsert" SelectMethod="GetByDriverID" 
      TypeName="GreenHomeDAL.DriverTableAdapters.DriverTableAdapter"&gt;
      &lt;InsertParameters&gt;
          &lt;asp:Parameter Name="DriverType" Type="String" /&gt;
          &lt;asp:Parameter Name="SessionID" Type="String" /&gt;
          &lt;asp:Parameter Name="StartDate" Type="String" /&gt;
          &lt;asp:Parameter Name="EndDate" Type="String" /&gt;
          &lt;asp:Parameter Name="Title" Type="String" /&gt;
          &lt;asp:Parameter Name="FirstName" Type="String" /&gt;
          &lt;asp:Parameter Name="Surname" Type="String" /&gt;
          &lt;asp:Parameter Name="DateOfBirth" Type="String" /&gt;
          &lt;asp:Parameter Name="Gender" Type="String" /&gt;
          &lt;asp:Parameter Name="Relationship" Type="String" /&gt;
          &lt;asp:Parameter Name="MaritalStatus" Type="String" /&gt;
          &lt;asp:Parameter Name="EmploymentStatus" Type="String" /&gt;
          &lt;asp:Parameter Name="Occupation" Type="String" /&gt;
          &lt;asp:Parameter Name="Business" Type="String" /&gt;
          &lt;asp:Parameter Name="SecondaryEmploymentStatus" Type="String" /&gt;
          &lt;asp:Parameter Name="SecondaryOccupation" Type="String" /&gt;
          &lt;asp:Parameter Name="SecondaryBusiness" Type="String" /&gt;
          &lt;asp:Parameter Name="LicenceType" Type="String" /&gt;
          &lt;asp:Parameter Name="TimeHeld" Type="String" /&gt;
          &lt;asp:Parameter Name="ClassSelect" Type="String" /&gt;
          &lt;asp:Parameter Name="Convictions" Type="String" /&gt;
          &lt;asp:Parameter Name="Claims" Type="String" /&gt;
          &lt;asp:Parameter Name="Resident" Type="String" /&gt;
          &lt;asp:Parameter Name="HowOften" Type="String" /&gt;
          &lt;asp:Parameter Name="Homeowner" Type="String" /&gt;
          &lt;asp:Parameter Name="NumOfCars" Type="String" /&gt;
          &lt;asp:Parameter Name="CarsOwned" Type="String" /&gt;
          &lt;asp:Parameter Name="ClaimFree" Type="String" /&gt;
          &lt;asp:Parameter Name="Refused" Type="String" /&gt;
          &lt;asp:Parameter Name="OtherConvictions" Type="String" /&gt;
          &lt;asp:Parameter Name="Disability" Type="String" /&gt;
          &lt;asp:Parameter Name="DriverSession" Type="String" /&gt;
          &lt;asp:Parameter Name="EntryType" Type="String" /&gt;
      &lt;/InsertParameters&gt;
  &lt;/asp:ObjectDataSource&gt;
  
  And the c# side:
  
   protected void PopulateDateFields()
          {
              int startYear = 1900;
              DropDownList uxDay = (DropDownList)uxDriverByID.FindControl("uxDay");
              DropDownList uxMonth = (DropDownList)uxDriverByID.FindControl("uxMonth");
              DropDownList uxYear = (DropDownList)uxDriverByID.FindControl("uxYear");
  
              uxYear.Items.Clear();
              uxMonth.Items.Clear();
              uxDay.Items.Clear();
              ListItem dayItem = new ListItem("DD", "0");
              ListItem monthItem = new ListItem("MM", "0");
              ListItem yearItem = new ListItem("YYYY", "0");
              uxDay.Items.Add(dayItem);
              uxMonth.Items.Add(monthItem);
              uxYear.Items.Add(yearItem);
              for (int i = (DateTime.Now.Year - 15); i &gt;= startYear; i--)
              {
                  uxYear.Items.Add(new ListItem(i.ToString(), i.ToString()));
              }
              for (int i = 0; i &lt; 12; i++)
              {
                  string num = i.ToString();
                  if (num.Length == 1)
                      num = "0" + num;
                  string month = CultureInfo.CurrentUICulture.DateTimeFormat.MonthNames[i];
                  uxMonth.Items.Add(new ListItem(month, num));
              }
              for (int i = 1; i &lt;= 31; i++)
              {
                  string num = i.ToString();
                  if (num.Length == 1)
                      num = "0" + num;
                  uxDay.Items.Add(new ListItem(num, num));
              }
              uxDay.DataTextField = "Day";
              uxDay.DataValueField = "Day";
              uxMonth.DataTextField = "Month";
              uxMonth.DataValueField = "Month";
              uxYear.DataTextField = "Year";
              uxYear.DataValueField = "Year";
          }   
  </code></pre>
  
  <p>I did plan to have code in the ItemInserting event, but it only goes into that with autopostback set to false, so nothing in it yet.</p>
  
  <p>Thanks</p>