Retrieving DataItem on Postback
I'm seeing if I can retrieve a DataItem from a datalist when I postback data. I want to retrieve an item of data from each row that was bound to the datalist.
I have tried this code, but it gives an error:-
Code:
For each item as DataListItem in dlst_policies.items
update_error.text =item.DataItem("policyref") & "<br />"
next
update_error is just a literal control on my page.
The error I get is:-
Object variable or With block variable not set.
As the datalist contains a List Of a class of mine, I've also tried
Code:
For each item as DataListItem in dlst_policies.items
Dim comm As PolicyPremiumBOL = item.DataItem
update_error.text = comm.policyref & "<br />"
next
But then I get an Object reference not set to an instance of an object error.
Is it possible to retrieve the data items when you're posting back or would I need to include a hidden field control or something that contains the data I want?
richyrich, July 21st, 2008 09:59 AM
Bookmarks