Click here to Skip to main content
15,907,225 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
Posted
Updated 17-Jul-11 21:13pm
v2

I don't think you can do this. Shared (static in C#) functions can only access shared members.
 
Share this answer
 
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.
 
Share this answer
 
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
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900