Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > databinding question

Reply
Thread Tools

databinding question

 
 
Jason S
Guest
Posts: n/a
 
      12-05-2003
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.Cont ains("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.


 
Reply With Quote
 
 
 
 
Hatim R
Guest
Posts: n/a
 
      12-05-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.Cont ains("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.
>
>



 
Reply With Quote
 
 
 
 
Jason S
Guest
Posts: n/a
 
      12-05-2003
Hatim,

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

Thanks,
Jason S.

"Hatim R" <(E-Mail Removed)> wrote in message
news:zP1Ab.69210$(E-Mail Removed) ble.rogers.com...
> 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" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.Cont ains("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.
> >
> >

>
>



 
Reply With Quote
 
Bin Song
Guest
Posts: n/a
 
      12-05-2003
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.
>
>"Hatim R" <(E-Mail Removed)> wrote in message
>news:zP1Ab.69210

$(E-Mail Removed).. .
>> 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" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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.Con tains

("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.
>> >
>> >

>>
>>

>
>
>.
>

 
Reply With Quote
 
Jason S
Guest
Posts: n/a
 
      12-05-2003
I suspected as much. That is not what I need.

Jason S.

"Bin Song" <(E-Mail Removed)> wrote in message
news:dcda01c3bb5e$e2f31fd0$(E-Mail Removed)...
> 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.
> >
> >"Hatim R" <(E-Mail Removed)> wrote in message
> >news:zP1Ab.69210

> $(E-Mail Removed).. .
> >> 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" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > 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.Con tains

> ("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.
> >> >
> >> >
> >>
> >>

> >
> >
> >.
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs ASP .Net 0 09-25-2007 11:54 PM
Gridview encoding, or how to run commands before gridview's default databinding, or, how do I disable default databinding at all? Sergei Shelukhin ASP .Net 1 11-12-2006 01:43 PM
DataGrid Custom Column Error when DataBinding "does not contain a definition for 'DataBinding'" Earl Teigrob ASP .Net Datagrid Control 1 03-01-2004 04:52 AM
simple databinding question aroth ASP .Net 4 02-23-2004 04:46 PM
Nested repeater databinding question Ed Allan ASP .Net 0 08-01-2003 01:10 PM



Advertisments