0

The Above Code has Runtime Error. Type ' Product' is not defined. Pls help me.

Imports System.Data

Partial Class insert
    Inherits System.Web.UI.Page
    Private SelectedProduct As Product

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            ddl1.DataBind()
        End If

        SelectedProduct = Me.GetSelectedProduct()
        Label1.Text = SelectedProduct.empno
        Label2.Text = SelectedProduct.empname
        Label3.Text = SelectedProduct.empsal
        Label4.Text = SelectedProduct.contactno
    End Sub
    Private Function GetSelectedProduct() As Product
        Dim dvProduct As DataView = CType( _
            AccessDataSource1.Select(DataSourceSelectArguments.Empty), DataView)
        dvProduct.RowFilter = "empno = '" & ddl1.SelectedValue & "'"
        Dim Product As New Product

        Product.empno = dvProduct(0)("empno").ToString
        Product.empname = dvProduct(0)("empname").ToString
        Product.empsal = dvProduct(0)("empsal").ToString
        Product.contactno = dvProduct(0)("contactno").ToString
        Return Product
    End Function
End Class
3
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by rohand
0

>The Above Code has Runtime Error. Type ' Product' is not defined. Pls help me.

Please define the Type "Product".

0

The Above Code has Runtime Error. Type ' Product' is not defined. Pls help me.

Imports System.Data

Partial Class insert
    Inherits System.Web.UI.Page
    Private SelectedProduct As Product

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            ddl1.DataBind()
        End If

        SelectedProduct = Me.GetSelectedProduct()
        Label1.Text = SelectedProduct.empno
        Label2.Text = SelectedProduct.empname
        Label3.Text = SelectedProduct.empsal
        Label4.Text = SelectedProduct.contactno
    End Sub
    Private Function GetSelectedProduct() As Product
        Dim dvProduct As DataView = CType( _
            AccessDataSource1.Select(DataSourceSelectArguments.Empty), DataView)
        dvProduct.RowFilter = "empno = '" & ddl1.SelectedValue & "'"
        Dim Product As New Product

        Product.empno = dvProduct(0)("empno").ToString
        Product.empname = dvProduct(0)("empname").ToString
        Product.empsal = dvProduct(0)("empsal").ToString
        Product.contactno = dvProduct(0)("contactno").ToString
        Return Product
    End Function
End Class

I say just make sure that your class name is not misspelled, i mean it should be correct name.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.