我在将字符串转换为piczard的SimpleImageUpload类型时遇到了问题,这是一个可以上传图片的控件。如果有人遇到这个问题,我很乐意得到一些帮助....
在我的代码中,我正在抓取ImageUploaderPerson1.ID.ToString(),我试图将其分配给SimpleImageUpload类型,以便稍后操作。
下面是我的代码:Dim Pictures As New Hashtable
Dim pic As DictionaryEntry
Dim retValPic As SimpleImageUpload = New SimpleImageUpload()
Dim button As String = hfPictureIndex.Value
PictureInfo.PictureIndex = Convert.ToInt16(button)
Pictures.Add("1", ImageUploaderPerson1.ID.ToString())
Pictures.Add("2", ImageUploaderPerson2.ID.ToString())
For Each pic In Pictures
If pic.Key.ToString() = button.ToString() Then
retValPic = pic.Value '*trying to convert it here!
'** Saving Picture
If retValPic.HasImage Then
End If
Next
尝试使用引用实际对象而不是哈希表的Dictionary。
Dim Pictures As New Dictionary(Of String, SimpleImageUpload)
Dim retValPic As SimpleImageUpload = New SimpleImageUpload()
Dim button As String = hfPictureIndex.Value
PictureInfo.PictureIndex = Convert.ToInt16(button)
Pictures.Add("1", ImageUploaderPerson1)
Pictures.Add("2", ImageUploaderPerson2)
For Each pic as KeyValuePair(Of String, SimpleImageUpload) In Pictures
If pic.Key.ToString() = button.ToString() Then
retValPic = pic.Value '*trying to convert it here!
'** Saving Picture
If retValPic.HasImage Then
End If
Next