1

我的用户控件(UCProducs)中有 3 个下拉列表(cbb_state、cbb_products、cbb_item),每个都有一个数据源(ods_state、ods_products、ods_item),并且我有我的 .aspx 页面,它正在使用这个 UserControl....此页面具有必须绑定我的用户控件中的 3 个下拉列表中的值的 ObjectDataSource...我尝试了一些示例,但没有一个对我有帮助。

这是我的 UserControl 代码文件:

Imports System.Data.SqlClient
Partial Class UCProducts
Inherits System.Web.UI.UserControl

Public Property Item() As Integer
    Get
        If cbb_item.SelectedValue <> "" Then
            Return cbb_item.SelectedValue
        Else
            Return 0
        End If
    End Get
    Set(ByVal value As Integer)
        cbb_item.SelectedValue = value
        Distrito = fc_produts.value)
        If value > 0 Then
            cbb_products.Enabled = True

        End If
    End Set
End Property

Public Property State() As Integer
    Get
        If cbb_state.SelectedValue <> "" Then
            Return cbb_state.SelectedValue
        Else
            Return 0
        End If
    End Get
    Set(ByVal value As Integer)
        If Not value = 0 Then
            cbb_state.SelectedValue = value

        End If

    End Set
End Property

Public Property Products() As Integer
    Get
        Return cbb_products.SelectedValue
    End Get
    Set(ByVal value As Integer)
        cbb_products.SelectedValue = value
    End Set
End Property




Private Function fc_pega_sub(ByVal index As Integer) As Integer

        'my code
End Function

Private Function fc_pega_distrito(ByVal value As Integer) As Integer

        'my code
End Function



Protected Sub cbb_regiao_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles cbb_regiao.SelectedIndexChanged
    'my code
End Sub
End Class

在我的 .aspx 页面中:

 <uc5:UCProduts ID="ucProd" runat="server" />

我怎么做?

4

1 回答 1

0

我终于做到了,哈哈,所以答案很简单......因为当我将 UserControl 放入我的页面时,我已经创建了我的属性“Products()”,我只需要引用绑定我的列的属性!这是解决方案:

<uc2:Products ID="Products" runat="server" Products='<%# Bind("fk_products") %>' />
于 2013-05-10T14:03:58.963 回答