databinding question

  • Thread starter Thread starter Jason S
  • Start date Start date
J

Jason S

I haven't been able to find a clear answer to this and I'm hoping someone
could enlighten me.

As pertains to databinding a control in a repeating fashion(datagrid,
repeater, etc.) what event would one handle to get a handle on things just
BEFORE the data is bound. To be clearer, not controlling the formatting of
the bound control(backcolor or what have you), but rather control the WAYor
even IF the data is bound at all.

For instance, in the context of active directory calls some results come
back in a non deterministic way. In one result of an ADSI query I could
have an item with a "phonenumber" property and the very next result could
have no such property. It simply isn't present. Kind of like a ragged
array I guess you could say. When the databinder gets to that entry it
throws an index out of range exception/COM exception, etc.

So back to my question... what event allows me to come in BEFORE the data is
bound and have the bindee dataitem there for inspection? Essentially,
control the entire process. It appears that ItemDataBound is after the fact
and is merely for tidying up. I couldn't tell if the DataBinding event or
the ItemCreated would help me get closer or not. They way I am working with
it now is by page level databinding statements such as:

<%#
((SearchResult)Container.DataItem).Properties.Contains("telephonenumber") ?
((SearchResult)Container.DataItem).Properties["telephonenumber"][0] :
"[blank]" %>

What is the code level equivalent of this action? This seems like such a
common thing to do but I can't find a good description of the process.

TIA,
Jason S.
 
Hi Jason,

If I understand you question properly you want to verify the data row by row
before it is bound. that's exactly what the ItemDataBound even is for. you
can get the event and check for the data that would appear you would need to
keep a copy of the data handy even in view state or in the cache to know
which row is supposed to go there

I hope this makes sense and helps you

Cheers Tim
 
Hatim,

Thanks for your reply. Does that event fire before or after the data is
bound to the control?

Thanks,
Jason S.

Hatim R said:
Hi Jason,

If I understand you question properly you want to verify the data row by row
before it is bound. that's exactly what the ItemDataBound even is for. you
can get the event and check for the data that would appear you would need to
keep a copy of the data handy even in view state or in the cache to know
which row is supposed to go there

I hope this makes sense and helps you

Cheers Tim
Jason S said:
I haven't been able to find a clear answer to this and I'm hoping someone
could enlighten me.

As pertains to databinding a control in a repeating fashion(datagrid,
repeater, etc.) what event would one handle to get a handle on things just
BEFORE the data is bound. To be clearer, not controlling the formatting of
the bound control(backcolor or what have you), but rather control the WAYor
even IF the data is bound at all.

For instance, in the context of active directory calls some results come
back in a non deterministic way. In one result of an ADSI query I could
have an item with a "phonenumber" property and the very next result could
have no such property. It simply isn't present. Kind of like a ragged
array I guess you could say. When the databinder gets to that entry it
throws an index out of range exception/COM exception, etc.

So back to my question... what event allows me to come in BEFORE the
data
is
bound and have the bindee dataitem there for inspection? Essentially,
control the entire process. It appears that ItemDataBound is after the fact
and is merely for tidying up. I couldn't tell if the DataBinding event or
the ItemCreated would help me get closer or not. They way I am working with
it now is by page level databinding statements such as:

<%#
((SearchResult)Container.DataItem).Properties.Contains("telephonenumber")
?
((SearchResult)Container.DataItem).Properties["telephonenumber"][0] :
"[blank]" %>

What is the code level equivalent of this action? This seems like such a
common thing to do but I can't find a good description of the process.

TIA,
Jason S.
 
The ItemDataBound event is raised after an item is data
bound to the Databoundable control. This event provides
you with the last opportunity to access the data item
before it is displayed on the client. After this event is
raised, the data item is nulled out and no longer
available.

Bin Song, MCP
-----Original Message-----
Hatim,

Thanks for your reply. Does that event fire before or after the data is
bound to the control?

Thanks,
Jason S.

Hi Jason,

If I understand you question properly you want to
verify the data row by
row
before it is bound. that's exactly what the ItemDataBound even is for. you
can get the event and check for the data that would
appear you would need
to
keep a copy of the data handy even in view state or in the cache to know
which row is supposed to go there

I hope this makes sense and helps you

Cheers Tim
and I'm hoping
someone handle on things
just
controlling the formatting
of rather control the
WAYor
very next result
could come in BEFORE the
data
is ItemDataBound is after the
fact
DataBinding event
or
the ItemCreated would help me get closer or not.
They way I am working
with
it now is by page level databinding statements such as:

<%#
((SearchResult)Container.DataItem).Properties.Contains ("telephonenumber")
?
((SearchResult)Container.DataItem).Properties ["telephonenumber"][0] :
"[blank]" %>

What is the code level equivalent of this action?
This seems like such
a

.
 
I suspected as much. That is not what I need.

Jason S.

Bin Song said:
The ItemDataBound event is raised after an item is data
bound to the Databoundable control. This event provides
you with the last opportunity to access the data item
before it is displayed on the client. After this event is
raised, the data item is nulled out and no longer
available.

Bin Song, MCP
-----Original Message-----
Hatim,

Thanks for your reply. Does that event fire before or after the data is
bound to the control?

Thanks,
Jason S.

Hi Jason,

If I understand you question properly you want to
verify the data row by
row
before it is bound. that's exactly what the ItemDataBound even is for. you
can get the event and check for the data that would
appear you would need
to
keep a copy of the data handy even in view state or in the cache to know
which row is supposed to go there

I hope this makes sense and helps you

Cheers Tim
I haven't been able to find a clear answer to this
and I'm hoping
someone
could enlighten me.

As pertains to databinding a control in a repeating fashion(datagrid,
repeater, etc.) what event would one handle to get a
handle on things
just
BEFORE the data is bound. To be clearer, not controlling the formatting
of
the bound control(backcolor or what have you), but rather control the
WAYor
even IF the data is bound at all.

For instance, in the context of active directory calls some results come
back in a non deterministic way. In one result of an ADSI query I could
have an item with a "phonenumber" property and the
very next result
could
have no such property. It simply isn't present. Kind of like a ragged
array I guess you could say. When the databinder gets to that entry it
throws an index out of range exception/COM exception, etc.

So back to my question... what event allows me to
come in BEFORE the
data
is
bound and have the bindee dataitem there for inspection? Essentially,
control the entire process. It appears that ItemDataBound is after the
fact
and is merely for tidying up. I couldn't tell if the
DataBinding event
or
the ItemCreated would help me get closer or not. They way I am working
with
it now is by page level databinding statements such as:

<%#
((SearchResult)Container.DataItem).Properties.Contains ("telephonenumber")
?
((SearchResult)Container.DataItem).Properties ["telephonenumber"][0] :
"[blank]" %>

What is the code level equivalent of this action?
This seems like such
a
common thing to do but I can't find a good description of the process.

TIA,
Jason S.


.
 
Back
Top