Wednesday, January 23, 2008

Use Enum in Object Data Source

JHA Performance Page uses Object Data Source to pick up Http Form Submitted data --- the so called two way data binding. For April 08 release, we need introduce Enum Type to model 3-states for Performance Type and the following class could be used to pick up Enum as input.

Public Enum PerformanceTypeEnum
Daily
Standard
AdjNonStandard
End Enum

Public Class MTData
public Function GetData(pt as PerformanceTypeEnum) as IList
End Class

<asp:ObjectDataSource id="ods1" TypeName="MTData" SelectMethod="GetData" OnSelecting="ods1_Selecting" >
<asp:SelectParameters >

<asp:Parameter Name='pt" type="String" >

Public Sub Ods1_Selectting (sender as Object, e as ObjectDataSourceEventArgs)
e.InputParameters("pt") = PerformanceTypeEnum.Daily
End Sub


Note that the parameter defined in the markup cannot have PerformanceTypeEnum as its type

No comments: