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

Embedded ListView question

2 Answers 69 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Jim
Top achievements
Rank 1
Jim asked on 02 Mar 2012, 04:39 PM
I'm working a project where there is a ListView embedded within another ListView. 
I'm having difficulty performing a databind on the embedded ListView when the user deletes an entry from it.  I receive "Object reference not set to an instance of an object" as an error.  The entry does get deleted but I'm unable to refresh the ListView to reflect the deleted entry.  Thanks very much for any assistance!

Code:

 

 

Protected Sub lvMissionSubTasks_ItemDeleting(sender As Object, e As Telerik.Web.UI.RadListViewCommandEventArgs) Handles lvMissionSubTasks.ItemDeleting

 

 

 

If TypeOf e.ListViewItem Is RadListViewItem Then

 

 

 

Dim lbl As Label = TryCast(e.ListViewItem.FindControl("lblItemID"), Label)

 

 

 

Dim de As New LaunchChecklist.BUS.Items

 

de.Delete(

 

CInt(lbl.Text))

 

 

 

'lvMissionSubTasks.DataBind()

 

 

 

Dim lv As RadListView = DirectCast(e.ListViewItem.FindControl("lvMissionLevel3SubTasks"), RadListView)

 

lv.DataBind()

 

 

End If

 

 

 

End Sub

 

2 Answers, 1 is accepted

Sort by
0
Jim
Top achievements
Rank 1
answered on 06 Mar 2012, 06:42 PM
Any suggestions?
0
Antonio Stoilkov
Telerik team
answered on 07 Mar 2012, 12:33 PM
Hello Jim,

The thrown exception occurs because one of defined variables value is null. The two possibilities are the lbl Label control or the lv RadListView control. In order to resolve your issue you could set up a breakpoint and see where the exception is thrown and from which of the two controls. The next step is to further investigate how to access the control so the FindControl method finds it successfully.

Kind regards,
Antonio Stoilkov
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
ListView
Asked by
Jim
Top achievements
Rank 1
Answers by
Jim
Top achievements
Rank 1
Antonio Stoilkov
Telerik team
Share this question
or