ItemCreated question

Discussion in 'ASP .Net Datagrid Control' started by BobU, Apr 23, 2005.

  1. BobU

    BobU Guest

    I've got a data grid that uses viewstate to maintain its state between
    posts. I also have a button outside of the data grid which, when clicked, in
    its server-side click event handler, sets a mode value (in viewstate) that I
    want the data grid's ItemCreated handler to act on. However, the ItemCreated
    event occurs before the button click event so it doesn't have the correct
    mode value.

    I've thought that I could set the mode value in a hidden field in
    client-side script whenever the button is clicked, and the data grid's
    ItemCreated event should then get the correct value. Is that the best way to
    handle this type of communication?

    Bob
     
    BobU, Apr 23, 2005
    #1
    1. Advertisements

  2. BobU

    Teemu Keiski Guest

    Hi,

    first of all, it depends a lot what you do in ItemCreated based on that
    value. But, to respond that quite common way to pass this is to rebind the
    grid entirely when something impacting on it changes.

    Sure, I thuink that setting the hidden field in client-script probably works
    in your scenario, but is there anything else involved in the ItemCreated?

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU


    "BobU" <> wrote in message
    news:...
    > I've got a data grid that uses viewstate to maintain its state between
    > posts. I also have a button outside of the data grid which, when clicked,
    > in its server-side click event handler, sets a mode value (in viewstate)
    > that I want the data grid's ItemCreated handler to act on. However, the
    > ItemCreated event occurs before the button click event so it doesn't have
    > the correct mode value.
    >
    > I've thought that I could set the mode value in a hidden field in
    > client-side script whenever the button is clicked, and the data grid's
    > ItemCreated event should then get the correct value. Is that the best way
    > to handle this type of communication?
    >
    > Bob
    >
     
    Teemu Keiski, Apr 24, 2005
    #2
    1. Advertisements

  3. BobU

    BobU Guest

    I've been able to do most of what I want to do without having to use
    ItemCreated. Since I am just massaging the data in the grid on each
    postback, I have been able to do that outside of the data grid's event
    handlers.

    But now I want to update a column total value in the footer. On a postback,
    I calculate the new total and set the column's FooterText property. But it
    never gets displayed. I guess that it has to be set in the ItemCreated (or
    ItemDataBound) but as I said, I'm not re-binding the grid to anything.

    Is there a way to force an ItemCreated event to occur?

    Bob
    "Teemu Keiski" <> wrote in message
    news:...
    > Hi,
    >
    > first of all, it depends a lot what you do in ItemCreated based on that
    > value. But, to respond that quite common way to pass this is to rebind the
    > grid entirely when something impacting on it changes.
    >
    > Sure, I thuink that setting the hidden field in client-script probably
    > works in your scenario, but is there anything else involved in the
    > ItemCreated?
    >
    > --
    > Teemu Keiski
    > ASP.NET MVP, AspInsider
    > Finland, EU
    >
    >
    > "BobU" <> wrote in message
    > news:...
    >> I've got a data grid that uses viewstate to maintain its state between
    >> posts. I also have a button outside of the data grid which, when clicked,
    >> in its server-side click event handler, sets a mode value (in viewstate)
    >> that I want the data grid's ItemCreated handler to act on. However, the
    >> ItemCreated event occurs before the button click event so it doesn't have
    >> the correct mode value.
    >>
    >> I've thought that I could set the mode value in a hidden field in
    >> client-side script whenever the button is clicked, and the data grid's
    >> ItemCreated event should then get the correct value. Is that the best way
    >> to handle this type of communication?
    >>
    >> Bob
    >>

    >
    >
     
    BobU, Apr 25, 2005
    #3
    1. Advertisements

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. lucy
    Replies:
    0
    Views:
    385
  2. Hardy Wang

    DataList's ItemCreated event

    Hardy Wang, Oct 27, 2003, in forum: ASP .Net
    Replies:
    3
    Views:
    3,803
    Hardy Wang
    Oct 27, 2003
  3. Binny
    Replies:
    2
    Views:
    1,140
    Binny
    Dec 10, 2003
  4. =?Utf-8?B?S2V2aW4gSGVjdG9y?=

    Repeater ItemCreated vs ItemDataBound

    =?Utf-8?B?S2V2aW4gSGVjdG9y?=, Apr 11, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    11,133
    Teemu Keiski
    Apr 11, 2004
  5. Lars Netzel
    Replies:
    2
    Views:
    445
    Lars Netzel
    Jul 9, 2004
  6. =?Utf-8?B?U291cmkgQ2hhbGxh?=

    Accessing DataGridItem in ItemCreated Event.

    =?Utf-8?B?U291cmkgQ2hhbGxh?=, Aug 28, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    5,101
    Souri Challa
    Aug 28, 2004
  7. Lars Netzel
    Replies:
    1
    Views:
    1,731
    Greg Burns
    Sep 10, 2004
  8. tshad

    DataLists ItemCreated question

    tshad, Mar 15, 2005, in forum: ASP .Net
    Replies:
    1
    Views:
    479
    Scott Allen
    Mar 15, 2005
Loading...