Nested datagrid event firing - item index of parent grid

A

Andy

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.
 
G

Guest

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;
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,743
Messages
2,569,478
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top