【问题标题】:Editing Nested GridView within a GridView在 GridView 中编辑嵌套的 GridView
【发布时间】:2013-06-21 04:32:34
【问题描述】:

我对 asp 服务器控件有点陌生,我在嵌套的 GridView 上遇到了困难。

我有我的 ParentGV 和 ChildGV

在ParentGV中打开Row没问题,显示ChildGV的行。

我在这里做的是:

  1. 回发到 ParentGV_RowCommand。
  2. 从 (GridView)sender 获取 ParentGV。
  3. 获取 rowIndex e.CommandArgument。
  4. 在 ParentGV 中找到对“ChildGV”的控制。
  5. BindData ParentGV。
  6. BindData 相关子级。

数据显示

即使进行插入也可以正常工作。 现在发件人是 ChildGV,对吧?

我为插入做什么:

  1. 回发到 ChildGV_RowCommand
  2. 从 (GridView)sender 获取 ChildGV。
  3. 获取页脚数据
  4. 将数据插入数据库 (MySQL)
  5. BindData ParentGV。
  6. BindData 相关子级。

插入正常,但 ChildGV.Visible 为假。

当我单击 ChildGV 行上的编辑按钮时,它变得一团糟。

所以我在编辑上做的是:

  1. 回发到 ChildGV_RowCommand
  2. 从 (GridView)sender 获取 ChildGV。
  3. “爬”上 ChildGV.Parent.Parent 以获得 ParentGVRow。
  4. “爬”上 ParentGVRow.Parent.Parent 的 ParentGV。
  5. 通过 -> ParentGV.SelectRow(ParentGVRow.RowIndex) 选择它
  6. 定义想要编辑的子行 -> ChildGV.EditIndex = Convert.ToInt32(e.CommandArgument)
  7. BindData ParentGV。
  8. BindData 相关子级。

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

感谢您的帮助

【问题讨论】:

    标签: asp.net gridview nested edit


    【解决方案1】:

    好的……发现了。 当 childGV 回发 on row 命令时,我必须将 rowIndex 保存在全局变量中,然后当我想将 ChildGV 绑定到 ParentGV 下时,我必须使用该全局变量。

    如果需要代码,请说明。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-12-03
      相关资源
      最近更新 更多