Nested datagrid event firing - item index of parent grid

Discussion in 'ASP .Net' started by Andy, Sep 29, 2005.

  1. Andy

    Andy Guest

    Hello,

    I have a datagrid within another datagrid. The innder datagrid
    contains a dropdownlist which fires an event as index change
    (OnSelectedIndexChanged). I can get the ItemIndex of the dropdownlist
    using this code below:

    ((DataGridItem)((DropDownList)Sender).NamingContainer).ItemIndex;

    This returns the ItemIndex of the dropdownlist of the inner datagrid.
    However, I need to know the ItemIndex of the outter datagrid (the
    parent datagrid) where the event is firing. So I use the following
    code, but it did not work.

    ((DataGridItem)((DropDownList)Sender).NamingContainer.Parent.FindControl("LineItemGrid")).ItemIndex;

    What should I do to get the ItemIndex of the parent datagrid.

    Thanks a lot.
     
    Andy, Sep 29, 2005
    #1
    1. Advertising

  2. Hi Andy,

    The NamingContainer to the child DataGridItem is the child DataGrid; the
    NamingContainer to the latter is the parent DataGridItem that you are trying
    to access.

    ((DataGridItem)((DataGrid)((DataGridItem)((DropDownList)Sender).NamingContainer).NamingContainer).NamingContainer).ItemIndex;
    --
    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "Andy" wrote:

    > Hello,
    >
    > I have a datagrid within another datagrid. The innder datagrid
    > contains a dropdownlist which fires an event as index change
    > (OnSelectedIndexChanged). I can get the ItemIndex of the dropdownlist
    > using this code below:
    >
    > ((DataGridItem)((DropDownList)Sender).NamingContainer).ItemIndex;
    >
    > This returns the ItemIndex of the dropdownlist of the inner datagrid.
    > However, I need to know the ItemIndex of the outter datagrid (the
    > parent datagrid) where the event is firing. So I use the following
    > code, but it did not work.
    >
    > ((DataGridItem)((DropDownList)Sender).NamingContainer.Parent.FindControl("LineItemGrid")).ItemIndex;
    >
    > What should I do to get the ItemIndex of the parent datagrid.
    >
    > Thanks a lot.
    >
    >
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Sep 29, 2005
    #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. Homa
    Replies:
    0
    Views:
    410
  2. Skowronek
    Replies:
    4
    Views:
    4,562
    ProgTalk
    Dec 4, 2007
  3. =?Utf-8?B?SmFtZXMgR2V1cnRz?=

    Bug with nested repeaters. Item events are called twice per item

    =?Utf-8?B?SmFtZXMgR2V1cnRz?=, Mar 15, 2007, in forum: ASP .Net
    Replies:
    4
    Views:
    977
    =?Utf-8?B?SmFtZXMgR2V1cnRz?=
    Mar 28, 2007
  4. Alan G Isaac
    Replies:
    5
    Views:
    422
    Colin J. Williams
    Aug 14, 2009
  5. Tomasz Chmielewski

    sorting index-15, index-9, index-110 "the human way"?

    Tomasz Chmielewski, Mar 4, 2008, in forum: Perl Misc
    Replies:
    4
    Views:
    336
    Tomasz Chmielewski
    Mar 4, 2008
Loading...

Share This Page