Passing an object as a parameter

Discussion in 'ASP .Net' started by Aymer, Nov 19, 2003.

  1. Aymer

    Aymer Guest

    Scenario: I have a datagrid object and a command object
    in code-behind module.
    dgFilings As DataGrid
    Dim oCmd As SqlCommand

    I have a function that I can re-use to bind different
    objects.

    Sub O_DataBind(oControl As Object, oCommand As SqlCommand)
    Dim oAdapter As SqlDataAdapter
    Dim oDataSet As DataSet

    oAdapter = New SqlDataAdapter(oCommand)
    oDataSet = New DataSet()
    oAdapter.Fill(oDataSet)

    oControl.DataSource = oDataSet
    oControl.DataBind()
    End Sub

    So, I would pass in the datagrid object and a command
    object into the function.
    O_DataBind(dgFilings, oCmd)

    I have "Option Strict True" turn on in my code-module.

    Problem: Apparently, what i am doing is illegal under the
    option strict rule. The error that it gives me
    is: "BC30574: Option Strict On disallows late binding"

    on line 123.
    Line 121: oAdapter.Fill(oDataSet)
    Line 122:
    Line 123: oControl.DataSource = oDataSet
    Line 124: oControl.DataBind()

    How do i go around this dilemma? There has to be a
    solution.

    thanxs in advance,
    aymer
    aymerb[@].yahoo.com
    Aymer, Nov 19, 2003
    #1
    1. Advertising

  2. Aymer

    Michael Per Guest

    Declare your oControl as a Control not as an Object. Control will have the
    DataSource property and DataBind method.

    "Aymer" <> wrote in message
    news:022f01c3aedd$27d56dd0$...
    > Scenario: I have a datagrid object and a command object
    > in code-behind module.
    > dgFilings As DataGrid
    > Dim oCmd As SqlCommand
    >
    > I have a function that I can re-use to bind different
    > objects.
    >
    > Sub O_DataBind(oControl As Object, oCommand As SqlCommand)
    > Dim oAdapter As SqlDataAdapter
    > Dim oDataSet As DataSet
    >
    > oAdapter = New SqlDataAdapter(oCommand)
    > oDataSet = New DataSet()
    > oAdapter.Fill(oDataSet)
    >
    > oControl.DataSource = oDataSet
    > oControl.DataBind()
    > End Sub
    >
    > So, I would pass in the datagrid object and a command
    > object into the function.
    > O_DataBind(dgFilings, oCmd)
    >
    > I have "Option Strict True" turn on in my code-module.
    >
    > Problem: Apparently, what i am doing is illegal under the
    > option strict rule. The error that it gives me
    > is: "BC30574: Option Strict On disallows late binding"
    >
    > on line 123.
    > Line 121: oAdapter.Fill(oDataSet)
    > Line 122:
    > Line 123: oControl.DataSource = oDataSet
    > Line 124: oControl.DataBind()
    >
    > How do i go around this dilemma? There has to be a
    > solution.
    >
    > thanxs in advance,
    > aymer
    > aymerb[@].yahoo.com
    >
    >
    Michael Per, Nov 20, 2003
    #2
    1. Advertising

  3. Aymer

    Aymer Guest

    the solution did not work. i declared oControl as a
    Control instead of an object. the error given
    states, "BC30456: 'DataSource' is not a member
    of 'System.Web.UI.Control'."

    so i still have a problem, but thanxs for the help.

    peace,
    aymer
    aymerb[@].yahoo.com
    Aymer, Nov 21, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. CoolPint
    Replies:
    3
    Views:
    696
    tom_usenet
    Dec 29, 2003
  2. Replies:
    4
    Views:
    501
    Matteo
    Mar 29, 2007
  3. Martin Rennix
    Replies:
    3
    Views:
    616
    Martin Rennix
    May 7, 2007
  4. Mister B
    Replies:
    8
    Views:
    527
    Nick Keighley
    Aug 26, 2010
  5. shaan
    Replies:
    16
    Views:
    395
    Jorgen Grahn
    Dec 25, 2013
Loading...

Share This Page