xtremeLogic
Programmer
Hi,
I have a nested Datalist structure where I have set the DataKeyField of my inner datalist to the pk of its underlying datasource. I have created the ItemCommand Handler for the inner datalist. When I try to process the delete command, I run into an error: Object reference not set to an instance of an object. I believe this is because I can't seem to be able to figure out which inner datlist to select. For example, say my outer list had 10 rows (with each row containing an inner data list), how would I know which inner datalist to process so the row could be deleted. I would greatly appreciate any help in this matter.
Here are some snippets of my code to show what I'm doing:
I have a nested Datalist structure where I have set the DataKeyField of my inner datalist to the pk of its underlying datasource. I have created the ItemCommand Handler for the inner datalist. When I try to process the delete command, I run into an error: Object reference not set to an instance of an object. I believe this is because I can't seem to be able to figure out which inner datlist to select. For example, say my outer list had 10 rows (with each row containing an inner data list), how would I know which inner datalist to process so the row could be deleted. I would greatly appreciate any help in this matter.
Here are some snippets of my code to show what I'm doing:
Code:
<asp:datalist id="dlSetDetails" OnItemDataBound="dlSetDetails_ItemDataBound" OnItemCommand="dlSetDetails_ItemCommand" cellSpacing="0" cellPadding="0" width="100%" BorderStyle="None" BackColor="#eeeeee" runat="server" RepeatColumns="1" DataSource='<%# GetSetInfo(DataBinder.Eval(Container.DataItem, "pk_orderDetailsID")) %>' DataKeyField="pk_orderDetailsPerTransmittalID" >
Code:
Sub dlSetDetails_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataListCommandEventArgs) Handles dlSetDetails.ItemCommand
Dim Command As String = e.CommandName
Select Case Command
Case "DeleteSetDetails"
Dim tempInnerDataList As DataList = CType(e.Item.FindControl("dlSetDetails"), DataList)
Dim deleteID As Integer = Convert.ToInt32(tempInnerDataList.DataKeys(e.Item.ItemIndex).ToString())
OrderAdmin.DeleteTransmittalSubInfo(deleteID)
bindData()
End Select
End Sub