If you handle DDL's SelectedIndexChanged event, you get the DDL instance
itself from the first parameter of event handler method. Ok, in the control
hierarchy DDL is inside a TableCell which is inside a DataGridItem (which
actually inherits from TableRow). Ok, so answer is that you cast the sender
event argument to DDL and get its parent's parent control something like:
DataGridItem item=(DataGridItem)((DropDownList)sender).Parent.Parent;
or straight with NamingContainer property:
DataGridItem item=(DataGridItem)((DropDownList)sender).NamingContainer;
The trick here is that DataGridItem can return the index of the DataGridItem
in Items collection of DataGrid (or DataItem itself if you are databinding)
which you can use to access the correct data source row. If you are not
databinding as you probably are not when this is run, you need to somehow
refetch the data.
--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist
http://blogs.aspadvice.com/joteke
Hi...
This should be simple I guess.. I have a dropdownbox as a template column in
my datagrid. When the selected item changes in this dropdown item, I need to
know the corresponding datarow in the datagrid. How do I determine this?
VJ