如何将多个网格视图行发送到另一个页面,并在中继器中填充这些行

How to send multiple gridview rows to another page and populate those rows in the repeater?

本文关键字:中继器 填充 网格 视图 另一个      更新时间:2023-09-26

我有一个显示数据行的中继器。我已经为用户使用了javascript来向中继器添加新行。

当添加新行时,其中一个单元格上会显示一个图像。单击该图像会打开一个新屏幕。

新屏幕可以搜索记录。搜索结果显示在数据网格中。

当用户单击任何一行时,相同的数据将添加到父页面中继器中新添加的行中。

我希望实现这个功能,以便可以同时添加多个资源。我把每一行的复选框和一个按钮都放进去了。单击按钮会将所有选中的行添加到父页面中的中继器中。

你能告诉我在发送到父页时如何处理这多行吗?

我正在使用parent.opener来调用并将值传递给父页。

感谢

您需要将所选行的数据传递回父行。像jquery这样的脚本库可以使它简单得多。例如,

$('#yourButton').click(function() {
   var data = [];
   // Assuming grid is CSS class for the grid and selector is CSS class for checkboxes 
   // that selects rows to copy
   $('.grid .selector:checked').parents('tr').each(function() {
        var rowData = [];
        // slice will ignore first td (assuming that it contains the selector checkbox)
        $(this).find('td').slice(1).each(function() { 
            rowData.push($(this).text());
        });
        data.push(rowData);
   });
   // now data will a jagged array - each element will be array of cell values
   // pass the data back to your opener
   ...
});

编辑:更正了一个小的拼写错误(家长而不是家长)。另请参阅这个jsfiddle,我为您提供了一个工作插图。