none
谁能帮我一下 RRS feed

  • 问题

  • 我开发了一个控件,设置了一个属性,相要引用页面上通过选择给这个属性付值我应该怎么做?先行谢谢

    代码如下

    Partial Class contorl_MyselectControl
        Inherits System.Web.UI.UserControl
        Dim _table As String
        Public WriteOnly Property table As String
            Set(value As String)
                _table = value
                Return
            End Set
        End Property
        Dim _ac As AccessDataSource
        ''' <summary>
        ''' 数据库链接控件
        ''' </summary>
        ''' <value></value>
        ''' <remarks></remarks>

    就是这个属性    Public WriteOnly Property ac As AccessDataSource
            Set(value As AccessDataSource)
                _ac = value
                Return
            End Set
        End Property
        Protected Sub Page_Init(sender As Object, e As EventArgs) Handles Me.Init
            _ac.SelectCommand = "SELECT  Format$([datatime],'Short Date') as dt FROM " & _table & " group by Format$([datatime],'Short Date')"
        End Sub
        Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load

        End Sub

        Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            Dim sql As String
            If Me.DropDownList1.SelectedValue = "no" Then
                sql = "select * from " & _table
            Else
                sql = "select * from " & _table & " where Format$([datatime],'Short Date')=" & Me.DropDownList1.SelectedValue
            End If
            If Me.DropDownList2.SelectedValue <> "no" Then
                If Me.DropDownList1.SelectedValue = "no" Then
                    sql = sql & " where keshi=" & Me.DropDownList2.SelectedValue
                Else
                    sql = sql & "and  keshi=" & Me.DropDownList2.SelectedValue
                End If
            End If
            _ac.SelectCommand = sql
        End Sub
    End Class

    我问的是当这个控件放到default.aspx上时,如何在属性ac中选择页面上的数据源控件




    • 已编辑 fqch1981 2012年10月9日 10:30
    2012年9月25日 9:23

全部回复