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

Recommended Answers

All 4 Replies

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

Please define the Type "Product".

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.

Thanks.

did you get the solution ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.