简体   繁体   English

嵌套gridview获取内部gridview页脚按钮上的外部gridview行索引

[英]Nested gridview get outer gridview row index on inner gridview footer button click

I have a nested gridview with a add button in the footer of one column and a textbox in the footer of another column. 我有一个嵌套的gridview,其中一列的页脚中有一个添加按钮,而另一列的页脚中有一个文本框。 When I click the add button, it would add a row into the nested gridview with the value that was entered in the textbox. 当我单击添加按钮时,它将在嵌套的gridview中添加一行,并在文本框中输入该值。 I am trying to figure out how to get the row index of the outer gridview in the add button click function. 我试图弄清楚如何在添加按钮单击功能中获取外部gridview的行索引。

Or is there a better way to accomplish what I have described above in general? 还是有一种更好的方法来完成我上面总体上所述的工作?

In the onclick event do: 在onclick事件中,请执行以下操作:

                                    //Button Row    //GridView      //Parent row
var parentRow = (GridViewRow)sender.NamingContainer.NamingContainer.NamingContainer;
var index = parentRow.RowIndex;

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM