2010年12月9日星期四

DataSource紹介 - ObjectDataSource

ObjectDataSourceは中間層ビジネス オブジェクトとして扱うのは普通です。
使う前に、対応ビジネスオブジェクトが必要です。
例:
===============
 Namespace Samples.DataSources
  Public Class TestObjectDataSource
    ' Select all employees.
    Public Function GetTestData(key as string) As DataTable
     return new DataTable
    End Function
   
    public Function Update(dt as DataTable) as Integer
     '更新
     return 0
    End Function
   
    public Function Delete(dt as DataTable) as Integer
     '削除
     return 0
    End Function
 End Class
End Namespace
===============

<html>
 <asp:ObjectDataSource
        ID="TestObjectDataSource1"
        runat="server"
        TypeName="Samples.DataSources.TestObjectDataSource"
        EnablePaging="true"
        SelectCountMethod="SelectCount"
        StartRowIndexParameterName="StartRecord"
        MaximumRowsParameterName="MaxRecords"
        SelectMethod="GetTestData" >
      </asp:ObjectDataSource>
 <asp:GridView ID="EmployeesGridView"
              DataSourceID="TestObjectDataSource1" >
 </asp:GridView>
</html>

没有评论: