This is a migrated thread and some comments may be shown as answers.

Save and Retrieve from Database

1 Answer 91 Views
ListBox
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 14 May 2012, 08:27 AM

Hi,

 

I am saving the transferred items from the RadListBoxDestination Box into one database field like so:-

Dim _RadListBoxDestinationText As String = Nothing
        For Each item As RadListBoxItem In RadListBoxDestination.Items
            _RadListBoxDestinationText = _RadListBoxDestinationText + item.Value.ToString + vbCrLf
        Next

'Save_RadListBoxDestinationText to the Database

The data saves OK
, but then when the user returns I need to repopulate the Destination box and I am trying to do it like so

Dim _DBString As String = _dr("EOT3CCa")
            Dim _DBSplitString As String() = _DBString.Split(New Char() {vbCrLf})
 
            Dim _Text As String
 
            For Each _Text In _DBSplitString
 
                Dim item As RadListBoxItem = RadListBoxSource.FindItemByText(_Text)
                RadListBoxSource.Transfer(item, RadListBoxSource, RadListBoxDestination)
              
            Next

I get an 'object reference not set..'
I can output the split string into an ordinary textbox just fine but not the RadListBox - it can't find the items.

Is there a better way to do this?

All help most appreciated.

Cheers,
Jon

1 Answer, 1 is accepted

Sort by
0
Dimitar Terziev
Telerik team
answered on 17 May 2012, 08:01 AM
Hi Jon,

Could you specify which reference is not set to an instance of an object? It seems to me that the following statement does not return a result:
Dim item As RadListBoxItem = RadListBoxSource.FindItemByText(_Text)

Please specify the transferring mode which you are using, is it copy or move?

All the best,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
ListBox
Asked by
Jon
Top achievements
Rank 1
Answers by
Dimitar Terziev
Telerik team
Share this question
or