A
adiel_g
I am trying to loop through a repeater to retrieve a dataitem field
but am getting a NullReferenceException.
I can find a checkbox control but cannot find a dataitem field. Here
is the code that is looping through the repeater:
Dim rc As RepeaterItemCollection = rptReport.Items
Dim ri As RepeaterItem
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim customer As String
For Each ri In rc
chkSelected = CType(ri.FindControl("chkCaseSel"),
System.Web.UI.WebControls.CheckBox)
If chkSelected.Checked Then
customer = ri.DataItem("customer") ' this is
the error line
getCustomersSelected.Add(casenum) ' this just adds
the customer to an array list
End If
Next
As you can see the line failing is:
customer = ri.DataItem("customer") ' this is the error line
The error is "NullReferenceException was unhandled by user code"
Thanks Before Hand,
Adiel
but am getting a NullReferenceException.
I can find a checkbox control but cannot find a dataitem field. Here
is the code that is looping through the repeater:
Dim rc As RepeaterItemCollection = rptReport.Items
Dim ri As RepeaterItem
Dim chkSelected As System.Web.UI.WebControls.CheckBox
Dim customer As String
For Each ri In rc
chkSelected = CType(ri.FindControl("chkCaseSel"),
System.Web.UI.WebControls.CheckBox)
If chkSelected.Checked Then
customer = ri.DataItem("customer") ' this is
the error line
getCustomersSelected.Add(casenum) ' this just adds
the customer to an array list
End If
Next
As you can see the line failing is:
customer = ri.DataItem("customer") ' this is the error line
The error is "NullReferenceException was unhandled by user code"
Thanks Before Hand,
Adiel