This is a discussion on Retrieving DataItem on Postback within the .Net Development forums, part of the Programming & Scripting category; I'm seeing if I can retrieve a DataItem from a datalist when I postback data. I want to retrieve an ...
| |||||||
|
#1
| ||||
| ||||
| 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
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
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? |
|
#2
| ||||
| ||||
| For your first error: Object variable or With block variable not set For the second problem...are you using one of the DataList events during the postback? DataList Events And the correct way, would be something like: Code: For each item as DataListItem in dlst_policies.items
Dim comm As PolicyPremiumBOL = CType(item.DataItem, PolicyPremiuBOL)
update_error.text = comm.policyref & "<br />"
Next
__________________ jmurrayhead If you agree with me... click the icon! If my post solved your problem, click the button in the lower right-hand corner of the post.If you like it here...throw us a few bones to help support us. Join our Folding team: DeveloperBarn Folding |
![]() |
|
| Bookmarks |
| Thread Tools | |
| Display Modes | |
| |
| ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Retrieving Web Data using Excel | mehere | Microsoft Office | 13 | May 22nd, 2008 03:14 PM |
| Finding Datalist Row on auto postback | richyrich | .Net Development | 1 | May 12th, 2008 04:52 AM |