2013-06-24 103 views
0

我对asp服务器控件很陌生,而且我在嵌套的GridView上遇到困难。在GridView中编辑嵌套的GridView

我有我的ParentGV和ChildGV

开口于ParentGV的行是没有问题的,并显示ChildGV的行。

我在这里做的是:

  1. 回发到ParentGV_RowCommand。
  2. 从(GridView)发件人处获得ParentGV。
  3. get rowIndex e.CommandArgument。
  4. 在ParentGV中找到“ChildGV”的控件。
  5. BindData ParentGV。
  6. 绑定数据相关子项。

数据显示

即使执行插入工作正常。 现在发件人是ChildGV,对不对?

我做插入:

  1. 回发到ChildGV_RowCommand
  2. GET ChildGV从(GridView的)发件人。
  3. 得到页脚数据
  4. 插入数据到数据库(MySQL的)
  5. BindData ParentGV。
  6. 绑定数据相关子项。

插入ok,但ChildGV.Visible为false。

当我点击ChildGV Row上的编辑按钮时,它会变得杂乱无章。

所以我做编辑是:

  1. 回发到ChildGV_RowCommand
  2. 从(GridView的)发件人得到ChildGV。
  3. 为ParentGVRow“爬”ChildGV.Parent.Parent。
  4. 为ParentGV“爬”ParentGVRow.Parent.Parent。
  5. 使其通过选择 - > ParentGV.SelectRow(ParentGVRow.RowIndex)
  6. 定义所需的行子编辑 - >ChildGV.EditIndex = Convert.ToInt32(e.CommandArgument)
  7. BindData ParentGV。
  8. 绑定数据相关子项。

我一直在寻找和阅读一段时间,只是没有工作。

感谢您的协助

回答

0

好的......发现它。 当childGV回发行命令我必须将rowIndex保存在一个全局变量,然后当我想绑定ParentGV下的ChildGV我必须使用该全局变量。

如果需要编码请指定。

+0

请分享code.Or任何更好的方法来做。 – Sribin