嵌套GridView的行数是零? [英] Row Count of nested GridView is Zero?!

查看:89
本文介绍了嵌套GridView的行数是零?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



我已经实现了本文中的代码 并且效果很好( http://msdn.microsoft.com/en-us/library/ms404832.aspx )。我唯一的问题是这个:



1)我已经在嵌套网格视图中添加了一个按钮,例如 < asp:ButtonField ButtonType ="按钮" CommandName =" Delete_Record"  Text =" Delete"  /> 

2)通过    GridView2_OnRowCommand嵌套网格视图的事件  



当点击嵌套网格中的按钮时,GridView2_OnRowCommand事件将触发但是'sender'或GridView2具有没有行(即Row.Count = 0)!!!我在嵌套网格中找不到数据,即使数据(行)在屏幕上显示为
。 



可以  ;有人请说明如何获取嵌套gridview的行?



非常感谢!!!

解决方案

你可以单独做到这一点这是使用按钮的CommandArgument。例如:¥

 
< asp 按钮 ID = " btnDelete" ; runtat = "服务器" 文字 = " ;删除" CommandArgument = '<%#DataBinder.Eval(Container.DataItem," ChildId")%>' Onclick = " btnChildDelete_Click" />


Hi All,

I've implemented the code in this article and it worked great (http://msdn.microsoft.com/en-us/library/ms404832.aspx). The only problem I have is this:

1) I have added a button to the nested gridview such as  <asp:ButtonField ButtonType="Button" CommandName="Delete_Record" Text="Delete" /> 
2) traped the event this button generates via the  GridView2_OnRowCommand Event of the nested gridview  

The GridView2_OnRowCommand event fires when the button in the nested grid is clicked BUT the 'sender' or GridView2 has no rows (i.e. Row.Count =0)!!! I can't find the data in my nested grid even though the data (rows) are displayed on the screen. 

Can someone please explain how to get the rows of the nested gridview??

Many thanks!!!

解决方案

You can do this in a seperate way that is using CommandArgument of a button. Ex:

<asp:button ID="btnDelete" runtat="server" Text="Delete" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "ChildId") %>' Onclick="btnChildDelete_Click" />


这篇关于嵌套GridView的行数是零?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆