I need to add the URL property to webbrowser1 (located on my form) from a dataset containing the URL, but am getting the error "Invalid cast from 'System.String' to 'System.Uri'. The column in datagridview1 is called link. I need the web browser URL to change with a corresponding textbox and listbox. I have the code correct on the listbox and textbox, as to when an item in the listbox is clicked the textbox changes. I need the webbrowser to change along with them. Here's what I have so far.

Public Shared Function loadRSSfeeds()
        'create dataset to hold data from XML 
        Dim ds As DataSet = New DataSet
        'clear listbox upon refreshing feed
        MainForm.descritptionListBox.DataBindings.Clear()

        ds.ReadXml("http://www.rotoworld.com/rss/feed.aspx?sport=nfl&ftype=news&count=12&format=rss")
        ds.ReadXml("http://rss.footballguys.com/bloggerrss.xml")
        ds.ReadXml("http://www.fantasyfootballstarters.com/podcast.xml")
        ds.ReadXml("http://cbssports.com/partners/feeds/rss/football_fantasy_news")
        ds.ReadXml("http://www.fantasysp.com/rss/nfl/columns/")
        ds.ReadXml("http://sports.yahoo.com/nfl/rss.xml")

        'fill DGV with data
        MainForm.DataGridView1.DataSource = ds.Tables("item")
        'add items from XML files to listbox

        MainForm.articleListBox.DataSource = ds.Tables("item")
        MainForm.articleListBox.DisplayMember = "title"
        MainForm.articleListBox.ValueMember = "title"
        n(MainForm.articleListBox.Refresh())

        'add description from selected news article to textbox
        MainForm.descritptionListBox.DataBindings.Add("Text", ds.Tables("item"), "description")

        'add URL to web browser corresponding to selected article and description
        MainForm.WebBrowser1.DataBindings.Add("Url", ds.Tables("item"), "link")
        'I get the error "Invalid cast from 'System.String' to 'System.Uri'."

    End Function

Recommended Answers

All 3 Replies

Try changing: MainForm.WebBrowser1.DataBindings.Add("Url", ds.Tables("item"), "link")

To: MainForm.WebBrowser1.DataBindings.Add("Url", ds.Tables("item"), "link", True)

This enables formatting of the value which invokes the property's TypeConverter.

TnTinMN,
That absoluetly worked. Thank you for your help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.