databinding question

Discussion in 'ASP .Net' started by Jason S, Dec 5, 2003.

  1. Jason S

    Jason S Guest

    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.
     
    Jason S, Dec 5, 2003
    #1
    1. Advertising

  2. Jason S

    Hatim R Guest

    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" <> wrote in message
    news:...
    > 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.
    >
    >
     
    Hatim R, Dec 5, 2003
    #2
    1. Advertising

  3. Jason S

    Jason S Guest

    Hatim,

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

    Thanks,
    Jason S.

    "Hatim R" <> wrote in message
    news:zP1Ab.69210$...
    > 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" <> wrote in message
    > news:...
    > > 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.
    > >
    > >

    >
    >
     
    Jason S, Dec 5, 2003
    #3
  4. Jason S

    Bin Song Guest

    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" <> wrote in message
    >news:zP1Ab.69210

    $...
    >> 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" <> wrote in message
    >> news:...
    >> > 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.
    >> >
    >> >

    >>
    >>

    >
    >
    >.
    >
     
    Bin Song, Dec 5, 2003
    #4
  5. Jason S

    Jason S Guest

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

    Jason S.

    "Bin Song" <> wrote in message
    news:dcda01c3bb5e$e2f31fd0$...
    > 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" <> wrote in message
    > >news:zP1Ab.69210

    > $...
    > >> 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" <> wrote in message
    > >> news:...
    > >> > 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.
    > >> >
    > >> >
    > >>
    > >>

    > >
    > >
    > >.
    > >
     
    Jason S, Dec 5, 2003
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Ed Allan

    Nested repeater databinding question

    Ed Allan, Aug 1, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    1,995
    Ed Allan
    Aug 1, 2003
  2. aroth

    simple databinding question

    aroth, Feb 23, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    3,127
    Martin Dechev
    Feb 23, 2004
  3. ORi

    Newbie question on databinding

    ORi, May 21, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    369
    Eliyahu Goldin
    May 21, 2004
  4. jobs
    Replies:
    0
    Views:
    1,631
  5. Earl Teigrob
    Replies:
    1
    Views:
    406
    Shravan
    Mar 1, 2004
Loading...

Share This Page