Property

Discussion in 'ASP .Net' started by shapper, Sep 24, 2007.

  1. shapper

    shapper Guest

    Hello,

    I have a page with 2 web controls. WC2 is inside WC1 as follows:

    Page

    |---- WC1

    |------ WC2

    On WC1 I have a GridView.

    I need to access a value in WC2 which is defined on the GridView
    RowEditing event in WC1.

    So what I did was:

    1. Create a property in WC2 named "MyVal"

    2. On my WC1 GridView RowEditing event I defined WC2.MyVal = "Test"

    I added on WC2 Load event the code Response.Write(Me.MyVal). I get
    nothing.

    What am I doing wrong?

    Thanks,

    Miguel
    shapper, Sep 24, 2007
    #1
    1. Advertising

  2. shapper

    Elroyskimms Guest

    On Sep 24, 5:23 am, shapper <> wrote:
    > I have a page with 2 web controls. WC2 is inside WC1 as follows:
    >
    > Page
    >
    > |---- WC1
    >
    > |------ WC2
    >
    > On WC1 I have a GridView.
    >
    > I need to access a value in WC2 which is defined on the GridView
    > RowEditing event in WC1.
    >
    > So what I did was:
    >
    > 1. Create a property in WC2 named "MyVal"
    >
    > 2. On my WC1 GridView RowEditing event I defined WC2.MyVal = "Test"
    >
    > I added on WC2 Load event the code Response.Write(Me.MyVal). I get
    > nothing.



    It sounds like you may be doing this in the wrong order. When you
    click to edit the GridView, the postback will first run the Load event
    handlers for WC1 and WC2. The last thing to be run is the WC2
    RowEditing event handler. So, at the time of WC2.Load, the Edit event
    code has not been executed, so the value has not been set. The WC2
    code which uses the property MyVal needs to be called after the
    RowEditing event in WC1. If you put it in its own method, you could
    call it:

    'Inside the WC1 RowEditing event
    WC2.MyVal="Test"
    WC2.MyFunctionName()

    This will run the function in WC2 after the MyVal has been set.

    HTH,

    -E
    Elroyskimms, Sep 24, 2007
    #2
    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. Eric Newton
    Replies:
    3
    Views:
    9,349
    Brock Allen
    Apr 4, 2005
  2. Joshua Beall
    Replies:
    1
    Views:
    410
    Bertilo Wennergren
    Dec 10, 2003
  3. Noozer
    Replies:
    10
    Views:
    2,037
    Mitja
    Oct 13, 2004
  4. Nathan Sokalski
    Replies:
    1
    Views:
    1,096
    =?Utf-8?B?SmVk?=
    Apr 29, 2006
  5. TS
    Replies:
    3
    Views:
    2,456
Loading...

Share This Page