User-830563764 posted
In a VS 2008 ASP.net 3.5 aspx.vb file, Response.Write(DDL.SelectedItem) worked very well.
But "Dim filenameDDL As String = DDL.SelectedItem.Text" did not. Then I tried the following codes
and found the problem -- Conversion from type 'ListItem' to type 'String' is not valid.
Why Response.Write(DDL.SelectedItem) worked so well?
How can convert ListItem to String, so that "Dim filenameDDL As String = DDL.SelectedItem.Text" will work?
Exception Details: System.InvalidCastException: Conversion from type 'ListItem' to type 'String' is not valid.
Source Error:
Line 70: Session.Add("FileSelected", DDL.SelectedItem) Line 71: 'Dim ItemSelected = DDL.SelectedItem Line 72: Dim filenameDDL As String = Session("FileSelected") Line 73: 'Dim filenameDDL As String = DDL.SelectedItem.Text Line 74: 'Dim fileSelected As String = DDL.Items.IndexOf(item:=DDL.SelectedItem)
|
Source File: C:\Documents and Settings\Jeffrey\My Documents\Visual Studio 2008\WebSites\MasterPagesTutorial01\ContentsDDLPlaceHolder.aspx.vb Line:
72