databinding question

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.
 
H

Hatim R

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
 
J

Jason S

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.
 
B

Bin Song

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

.
 
J

Jason S

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.


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

DataBinding 0
DataBinding 1
Databinding 1
Complex databinding 1
Postback and databinding question 1
databinding 6
DropDownList and Databinding 3
Inline Calculations for Databinding 5

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,576
Members
45,054
Latest member
LucyCarper

Latest Threads

Top