日期:2014-05-18  浏览次数:20413 次

提一个关于GirdView的RowCommand中的e.CommandSource问题.
网上查了相关资料,也试验过.e.CommandSource是GirdView对象.但通过这样的语句却可以得到行索引,这是怎么回事呢.
((GridViewRow)(((Button)(e.CommandSource)).Parent.Parent)).RowIndex;
((Button)(e.CommandSource)).Parent.Parent)不应该是页对象了吗?

------解决方案--------------------
System.Web.UI.WebControls.GridViewRow rows = (GridViewRow)((Control)sender).Parent.Parent;//获取对于ui层次结构中服务器控件的父控件的父控件的引用
然后用rows.findcontrol('')就可以获取 gridview中模板列中的控件,和楼主的疑惑一样,期待高手。