Hi,
The items transfer fine between the two list boxes unless its the last item in the list box, where I get the following error:
Error occurs on first line of RadListBoxContacts_Transferred (VB code)
e.SourceListBox.SelectedItem.DataKey
Error:
'Object reference not set to an instance of an object.'
please see code below:
ASPX
VB
The last four lines are executed in the Page_Load to initially populate the list boxes
As can be seen above the list boxes are re-bound to the database via a web service every time an item is inserted or deleted.
Any help or pointes in the right direction would be great.
Many Thanks.
The items transfer fine between the two list boxes unless its the last item in the list box, where I get the following error:
Error occurs on first line of RadListBoxContacts_Transferred (VB code)
e.SourceListBox.SelectedItem.DataKey
Error:
'Object reference not set to an instance of an object.'
please see code below:
ASPX
<telerik:RadListBox ID="RadListBoxContacts" runat="server" Skin="Telerik" AutoPostBack="true" |
AutoPostBackOnTransfer="true" DataKeyField="contactID" DataTextField="Description" |
Width="240px" Height="200px" AllowTransfer="true" TransferToID="RadListBoxServiceContacts" |
ButtonSettings-ShowTransferAll="false" EnableViewState ="true"> |
<ButtonSettings ShowTransferAll="False" /> |
</telerik:RadListBox> |
<telerik:RadListBox ID="RadListBoxServiceContacts" runat="server" Skin="Telerik" |
DataKeyField="contactID" DataTextField="Description" Width="245px" Height="200px" |
AutoPostBack="True" EnableViewState ="true" > |
</telerik:RadListBox> |
VB
Private Sub RadListBoxServiceContacts_Deleted(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadListBoxEventArgs) Handles RadListBoxServiceContacts.Deleted |
Session("Avalability") = "Delete" |
Me.lblServiceContactDescription.Text = "Select a contact to view details" |
Me.lblServiceContactDetails.Text = "" |
End Sub |
Private Sub RadListBoxServiceContacts_Inserted(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadListBoxEventArgs) Handles RadListBoxServiceContacts.Inserted |
Session("Avalability") = "Insert" |
Me.lblContactDescription.Text = "Select a contact to view details" |
Me.lblContactDetails.Text = "" |
End Sub |
Private Sub RadListBoxContacts_Transferred(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadListBoxTransferredEventArgs) Handles RadListBoxContacts.Transferred |
Dim contactID As String = CStr(e.SourceListBox.SelectedItem.DataKey) |
Dim serviceID As String = CStr(Me.RadListBoxServices.SelectedItem.DataKey) |
If CStr(Session("Avalability")) = "Delete" Then |
objWebService.removeContactFromService(contactID, serviceID) |
ElseIf CStr(Session("Avalability")) = "Insert" Then |
objWebService.addContactToService(contactID, serviceID) |
End If |
Me.RadListBoxContacts.Items.Clear() |
Me.RadListBoxServiceContacts.Items.Clear() |
Me.RadListBoxServiceContacts.DataSource = objWebService.getServicesContacts(CInt(Me.RadListBoxServices.DataKeys.Item(Me.RadListBoxServices.SelectedIndex))) |
Me.RadListBoxServiceContacts.DataBind() |
Me.RadListBoxContacts.DataSource = objWebService.getEmployeeContactsNotInService(CInt(Me.RadListBoxServices.DataKeys.Item(Me.RadListBoxServices.SelectedIndex)), Me.RadComboBoxSelectedEmployee.SelectedValue, "") |
Me.RadListBoxContacts.DataBind() |
End Sub |
The last four lines are executed in the Page_Load to initially populate the list boxes
As can be seen above the list boxes are re-bound to the database via a web service every time an item is inserted or deleted.
Any help or pointes in the right direction would be great.
Many Thanks.