Groups > Asp .Net > Data Access and ObjectDataSource Control > Re: ObjectDataSource




ObjectDataSource

ObjectDataSource
Tue, 1 Apr 2008 18:29:27 +0000
I'm a newbie.

 I have a typed dataset in my DAL.  It contains a UsersTableAdapter.  The
UserTableAdapter has a function called GetUserIDByASPNETUserID.

 I have a class in my BLL called UsersBLL and it contains the following:

 

Public Class UsersBLL

    Private _usersAdapter As UsersTableAdapter = Nothing
    Protected ReadOnly Property Adapter() As UsersTableAdapter
        Get
            If _usersAdapter Is Nothing Then
                _usersAdapter = New UsersTableAdapter
            End If

            Return _usersAdapter
        End Get
    End Property

    <System.ComponentModel.DataObjectMethodAttribute _
        (ComponentModel.DataObjectMethodType.Select, True)> _
    Public Function GetUsers() As timepiece.UsersDataTable
        Return Adapter.GetUsers
    End Function

    <System.ComponentModel.DataObjectMethodAttribute _
        (ComponentModel.DataObjectMethodType.Select, False)> _
    Public Function GetUserIDByASPNETUserID(ByVal ASPNETUserID As Guid) As
timepiece.UsersDataTable
        Return Adapter.GetUserIDByASPNETUserID(ASPNETUserID)
    End Function

 In my presentation layer, I have a page with a login control named login1.

In the Login1_LoggedIn event, I want to call the GetUserIDByASPNETUserID in my
UsersBLL class.

I assume I used a objectdatasource.  If so, how do I use it without binding it
to a control?

Thanks,

SC
Post Reply
Re: ObjectDataSource
Tue, 1 Apr 2008 18:50:28 +0000
Hi ,

you can use the class methods by creating an instance of the business class as
follows:

dim Mybll as new UsersBLL

dim users as  UsersDataTable =Mybll.GetUserIDByASPNETUserID(
Membership.GetUser().ProviderUserKey)

then you can get the user by accessig the first row of the retunrned table 

dim CurrentUSer as UsersRow=UsersDataTable (0)
Post Reply
Re: ObjectDataSource
Tue, 1 Apr 2008 19:01:25 +0000
Thanks...this will work!
Post Reply
about | contact