⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 othersetting.ascx.vb

📁 如果不使用IIS,请先运行 XSP.exe,待提示已侦听 8080端口后
💻 VB
字号:
Imports System.Collections.Generic


Partial Class controls_OtherSetting
    Inherits System.Web.UI.UserControl


    Private _datasource As Dictionary(Of String, String) = New Dictionary(Of String, String)
    Public ReadOnly Property DataSource() As Dictionary(Of String, String)

        Get

            If ViewState("ds") Is Nothing Then
                ViewState("ds") = _datasource
            End If

            Return CType(ViewState("ds"), Dictionary(Of String, String))
        End Get
    End Property


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

        For i As Integer = 0 To dlSettings.Items.Count - 1
            Dim key As String = CType(dlSettings.Items(i).FindControl("lblKey"), Label).Text
            Dim value As String = CType(dlSettings.Items(i).FindControl("txtValue"), TextBox).Text
            
            DataSource(key) = value

        Next


    End Sub

    Private Sub BindData()
        dlSettings.DataSource = DataSource
        dlSettings.DataBind()
    End Sub

    'Protected Sub dlSettings_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles dlSettings.ItemCommand
    '    If e.CommandName = "D" Then
    '        DataSource.Remove(e.CommandArgument)
    '        BindData()

    '    End If
    'End Sub

    Protected Sub btnAdd_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAdd.Click
        If txtKey.Text <> "" Then

            Try
                DataSource.Add(txtKey.Text, txtValue.Text)

                txtKey.Text = ""
                txtValue.Text = ""

                BindData()
            Catch ex As ArgumentException
                lblerr.Text = ex.Message

            End Try


        End If
    End Sub
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -