私有共享功能中的下拉列表值 [英] dropdown list value in private shared function

查看:71
本文介绍了私有共享功能中的下拉列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在网页上有一个下拉列表,要在私有共享功能中获取期望值,怎么可能
预先感谢

I have a dropdown list on webpage and to get delected value in private shared function how is it possible
thanx in advance

Private Shared Function GetConnectionString() As String
      
        Dim connString As String = "Integrated Security=SSPI;" + "Initial Catalog=" & dropdownlist1.SelectedValue & ";" + "Data Source=den;" + "Integrated Security=True;" + "Pooling=False;"

        GetConnectionString = connString
End Function

推荐答案

我认为您无法做到这一点.共享(在C#中为静态)函数只能访问共享成员.
I don''t think you can do this. Shared (static in C#) functions can only access shared members.


这将行不通.您必须重写GetConnectionString函数以接受参数,然后从调用代码中传入所选的值.
This is not going to work. You''ll have to rewrite your GetConnectionString function to accept a parameter then pass in the selected value from your calling code.


我解决了它.

共享的str作为字符串
私有共享函数GetConnectionString()作为字符串
Dim connString As String =集成安全性= SSPI;"; +初始目录='''' & Str& "'';" +"数据源= den;" +集成安全性= True;"; +" Pooling = False;"
返回connString

最终功能
受保护的子DropDownList1_SelectedIndexChanged(ByVal发送者作为对象,ByVal e作为System.EventArgs)处理DropDownList1.SelectedIndexChanged
str = DropDownList1.SelectedItem.ToString()
str =集成安全性= SSPI;"; +初始目录='''' & Str& "'';" +"数据源= den;" +集成安全性= True;"; +" Pooling = False;"

结束Sub
i solved it.

Shared str As String
Private Shared Function GetConnectionString() As String
Dim connString As String = "Integrated Security=SSPI;" + "Initial Catalog=''" & str & "'';" + "Data Source=den;" + "Integrated Security=True;" + "Pooling=False;"
Return connString

End Function
Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DropDownList1.SelectedIndexChanged
str = DropDownList1.SelectedItem.ToString()
str = "Integrated Security=SSPI;" + "Initial Catalog=''" & str & "'';" + "Data Source=den;" + "Integrated Security=True;" + "Pooling=False;"

End Sub


这篇关于私有共享功能中的下拉列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆