Thursday, February 3, 2011

dropdown function

 Public Sub CBSC_drop_value_bind(ByVal sql As String, ByVal text As String, ByVal value As String, ByVal build As DropDownList)
        Dim dr As SqlDataReader
        If (OpenConnection()) Then
            SRP_cmd = SRP_con.CreateCommand
            SRP_cmd.CommandType = CommandType.Text
            SRP_cmd.CommandText = sql
            errLog.Info(sql)
            dr = SRP_cmd.ExecuteReader
            build.Items.Clear()
            build.DataSource = dr
            build.DataTextField = text
            build.DataValueField = value
            build.DataBind()
            build.Items.Insert(0, "--Select--")
            dr.Close()
            CloseConnection()
        End If
    End Sub

No comments :

Post a Comment