I have an ASP.NET app with code similar to the ProjectTracker sample. Here is a snippet I have:
Private Function GetEmployee() As Employee
Dim businessObject As Object = Session("currentObject")
If businessObject Is Nothing OrElse _
Not TypeOf businessObject Is Employee Then
Dim et As String = Request.QueryString("EmployeeID")
If Not String.IsNullOrEmpty(et) Then
businessObject = Employee.GetByEmployeeID(et)
businessObject = Employee.NewEmployee
businessObject.EmployeeType = 1
Session("currentObject") = businessObject
Catch ex As System.Security.SecurityException
Return CType(businessObject, Employee)
On the form I have 2 CslaDatasource objects. One for the Employee and one to populate a combobox with EmployeeTypes.
The problem I am having is that I want to set the EmployeeType to 1 but it is not getting preselected in the combobox. The form uses a FormView for binding and it binds fine in Edit mode but in insert mode the line where I set the EmployeeType to 1 does nothing.
Anybody have any ideas?
Well I solved the problem. It had to do with the FormView being in insert mode. In this case you need to set the values of the controls themselves to the default values in the object.
Copyright (c) Marimer LLC