ajie
yingwu

#Region "绑定chekBoxList数据源"
        Public Sub BindCheckBoxList()
            '获取数据字典项
            Dim controls As New CommonDDLController
            Dim ddlDataDictonary As List(Of NameValueInfo) = controls.GetCommonDDLList("TaskType", Me.PortalId, True)
            cboxListTaskType.DataSource = ddlDataDictonary
            cboxListTaskType.DataTextField = "Text"
            cboxListTaskType.DataValueField = "Value"
            cboxListTaskType.DataBind()
        End Sub
#End Region


Edit页面:
                    '设置checkBoxList的选中项
                    If .tTaskType.Length > 0 Then
                        Dim tTask() As String
                        tTask = .tTaskType.Split(",")
                        For i As Integer = 0 To tTask.Length - 1
                            For j As Integer = 0 To cboxListTaskType.Items.Count - 1
                                If cboxListTaskType.Items(j).Value = tTask(i) Then
                                    cboxListTaskType.Items(j).Selected = True
                                End If
                            Next
                        Next
                    End If

                '循环获取任务类型
                Dim taskType As String = String.Empty
                For i As Integer = 0 To cboxListTaskType.Items.Count - 1
                    If cboxListTaskType.Items(i).Selected Then
                        taskType = taskType & (cboxListTaskType.Items(i).Value & ",")
                    End If
                Next
                '去掉最后一个逗号 
                If taskType(taskType.Length - 1) = "," Then
                    .tTaskType = taskType.Remove(taskType.Length - 1, 1)
                Else
                    .tTaskType = taskType
                End If

 

Detail页面:

   cboxListTaskType.Text = getDDLItemText(.tTaskType, "TaskType")          '任务类型

  ''' <summary>
        ''' 将数据字典中的Value转成Text
        ''' </summary>
        ''' <param name="myProperty">对应数据字典项的值(即对象相应的属性)</param>
        ''' <param name="dataDictionaryName">数据字典名</param>
        ''' <returns>对应数据字典值的Text</returns>
        ''' <remarks></remarks>
        Private Function getDDLItemText(ByVal myProperty As String, ByVal dataDictionaryName As String) As String
            Dim result As String = String.Empty             '接收最终结果 
            Dim controls As New CommonDDLController
            If myProperty.Length > 0 Then
                Dim tTask() As String
                tTask = myProperty.Split(",")
                Dim ddlDataDictonary As List(Of NameValueInfo) = controls.GetCommonDDLList(dataDictionaryName, Me.PortalId, True)
                Dim dItem As NameValueInfo
                For j As Integer = 0 To tTask.Length - 1
                    Try
                        For Each dItem In ddlDataDictonary
                            If dItem.Value = tTask(j) Then
                                result += dItem.Text + "\"
                            End If
                        Next
                    Catch ex As Exception
                        Return Null.NullString
                    End Try
                Next
                Return result.Remove(result.Length - 1, 1)
            End If
            Return Null.NullString
        End Function

posted on 2009-03-15 21:21  ajie  阅读(250)  评论(0)    收藏  举报