gregm
Posts: 21
|
| Posted: 03/26/2007, 1:17 AM |
|
I have a label with a BeforeEvent which I would like to access a field from the table. This is on a calender control.
In the BeforeEvent I have this statement
'Label MonthDate Event BeforeShow. Action Custom Code @26-73254650
' -------------------------
' Write your own code here.
' -------------------------
Dim Cl as String
Cl = Item.rawdata("COLOUR")
'End Label MonthDate Event BeforeShow. Action Custom Code
Basically, before each cell is drawn on the calender, I want to get the field value of the cell which says what colour it will need to be.
Accessing the data gives an "Object reference not set to an instance of an object."
I understand the error, but need to know how the object model for data access is working in CCS to get round this, it's driving my nuts. I would have thought that at this point, the page already had a copy of the record to enable it to get the data for the calender???
Any help appreciated,
Thanks,
Greg
_________________
Greg Martin
gmartin@microresource.co.uk |
 |
 |
gregm
Posts: 21
|
| Posted: 03/27/2007, 5:38 AM |
|
Ok to answer this question myself. I'm starting to understand the CCS event model a little more.
The calender has a different events to trigger which objects are returned, in this case the EventRow returns the current datarow which can then be accessed at field level.
In the case of the calender you can only get a reference to the dataset object when
e.Item.ItemType = CCCalendarItemType.EventRow
Dim MyField As String
MyField = DataItem.RawData("COLOUR")
My original code was at CCCalendarItemType.DayHeader, which has no dataset object so coming back with a object reference error makes sense!
I've not looked yet, but I will make an assumption that all the builders use a similar event model for reading through the data.
Thanks,
Greg
For example
Quote gregm:
I have a label with a BeforeEvent which I would like to access a field from the table. This is on a calender control.
In the BeforeEvent I have this statement
'Label MonthDate Event BeforeShow. Action Custom Code @26-73254650
' -------------------------
' Write your own code here.
' -------------------------
Dim Cl as String
Cl = Item.rawdata("COLOUR")
'End Label MonthDate Event BeforeShow. Action Custom Code
Basically, before each cell is drawn on the calender, I want to get the field value of the cell which says what colour it will need to be.
Accessing the data gives an "Object reference not set to an instance of an object."
I understand the error, but need to know how the object model for data access is working in CCS to get round this, it's driving my nuts. I would have thought that at this point, the page already had a copy of the record to enable it to get the data for the calender???
Any help appreciated,
Thanks,
Greg
_________________
Greg Martin
gmartin@microresource.co.uk |
 |
 |
|