Problem with FormView

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lloyd Sheen

    #1

    Problem with FormView

    Ok I have a new page which I want to use a FormView. I create an object
    which exposes a method returning a list(of Server). Now in the designer I
    can drop the FormView on the page, create the ObjectDataSourc e from the
    method and I see all the properties.

    Ok now my code (object)

    Imports Microsoft.Visua lBasic
    Imports Microsoft.SqlSe rver.Management .Smo
    Imports Microsoft.SqlSe rver.Management .Common
    imports System.Collecti ons.Generic

    Public Class SQLServer
    private fgss as new list(of Server)

    public sub new()

    End Sub

    public sub new(fgs as server)

    fgss.Add(fgs)
    End Sub

    public function GetSever() as list(of server)
    return fgss
    End Function

    End Class

    and in the page load of the page:

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As
    System.EventArg s) Handles Me.Load
    If Me.Session.Item (STR_LoginInfo) IsNot Nothing Then
    linfo = Me.Session.Item (STR_LoginInfo)
    xServer = linfo.SQLServer
    If xServer Is Nothing Then
    Exit Sub
    End If
    else
    linfo = New LoginInfo
    linfo.ServerNam e = STR_QLExpress
    linfo.UseIntegr atedSecurity = True
    xServer = linfo.SQLServer
    Session.Add(STR _LoginInfo, linfo)
    End If

    dim ss as New SQLServer (xserver)

    me.FormView1.Da taSourceID=noth ing
    me.FormView1.Da taSource=ss
    me.FormView1.Da taBind()

    End Sub


    The line me.FormView1.Da taSource=ss tells me that the source "Data source is
    an invalid type. It must be either an IListSource, IEnumerable, or
    IDataSource." Now all was good in the designer so why the problem???

    LLoyd Sheen

Working...