Ok, I am going to try and give a very bried yet detailed description of what I need to accomplish.
First, I have a LinqToSQL datacontext defined that has an employee object. I then created a BLL (partial of employee) that handles my validations, inserts, updates etc. Everthing is good at this point. Next, I created a detailsview with an object data source binding to my select/update/insert methods on my Employee object. This is good too, data pulls like it should, updates, inserts like it should except for one issue. I am having trouble with drop down list inside of the details view. These are required fields, cannot be null. When that constraint is dropped, the code functions just fine.
Code Snippet of details view - fields abbreviated to show relevant information.
<asp:DetailsView ID="grd_empDetails" runat="server" DataSourceID="empDataSource" DataKeyNames="EmployeeID" DefaultMode="Insert" AutoGenerateRows="false">
<Fields>
<asp:BoundField HeaderText="First Name" DataField="FirstName" />
<asp:TemplateField HeaderText="Type of Employee">
<ItemTemplate>
<asp:DropDownList ID="empType" runat="server" DataValueField="empType" AppendDataBoundItems="true">
<asp:ListItem Text="Full Time" Value="1" />
<asp:ListItem Text="Part Time" Value="2" />
<asp:ListItem Text="Subcontractor or 1099" Value="3" />
<asp:ListItem Text="Intern" Value="4" />
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowInsertButton="true" ShowCancelButton="true" />
</Fields>
</asp:DetailsView>
When the insert method is called, the empType is always returned as Nothing (empType is the database field).
What is the proper way to attach the value of the dropdownlist to my object so that it can be properly created in the database? Most of my searches keep telling me how to bind a dropdownlist to an object data source, but that is not what I need to do. This is a basic drop down list, 4 items that will never change. Would it make sense to use just a standard HTML select tag here or would that even help.
Thanks for looking, let me know if you need any more information.