有我一個下拉列表選擇,選擇的值將是ID,類型是GUID,目前我的選擇按鈕的代碼是可能將字符串轉換爲GUID?
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim Selection As String = Nothing
If Not DropDownList3.SelectedValue Is Nothing Then Selection = DropDownList3.SelectedValue
Session("Selected") = Selection
End Sub
然後我有
Dim ID is guid
ID = Session("Selected")
然後我需要執行sql這樣作爲select * from .. where ID=..
問題發生在ID = Session("Selected")
,因爲ID
是GUID
,而Session("Selected")
是string
我不知道是否有辦法處理它? 非常感謝您的幫助!
可能重複的[C#:測試如果字符串是一個GUID沒有拋出異常?](http://stackoverflow.com/questions/104850/c-test-if-string-is-a-guid-without-throwing - 異常) – TFD