ASP.Net - ObjectDataSource

The Object Datasource is an object which binds a gui object to a specially written business object

Sample

1
2
3
4
5
6
7
<asp:ObjectDataSource ID="odsSomeAreAvailable" runat="server"TypeName="ACAD2SDE.BL_Acad_Reservation" SelectMethod="GetAL_Reserved_InAPlan" > 
<SelectParameters>
<asp:ControlParameter ControlID="txtProjectNo" Name="PlanNo" PropertyName="Text"Type="String" /> <asp:Parameter DefaultValue="False" Name="ShowAll" Type="Boolean" />
<asp:Parameter DefaultValue="No" Name="AddBlank" Type="String" />
<asp:Parameter DefaultValue="" Name="SortParameter" Type="String" />
</SelectParameters>
</asp:ObjectDataSource>

Notes:

  • ObjectDataSource objects do not recognise the Optional attribute of a function. Consequently you must provide parameters for each argument of a function whether or not it is optiona..

Events:

  • ObjectDataSource.Selecting - this event is raised when the ObjectDataSource is being used to grab a set of objects. I sometimes use it when the control is bound a grid view. If the method has parameters which I just cant handle any other way, then this makes a good emergency. Pity the code is that much harder to read as a result.