if (Page.EventArgument == "FloatingFrameSubmitParentPostBackArgument")
{
if (Page.DataContract.GetValueByName("IsRefresh") == null)
{//从这里开始
List
if (guid_one.Data is DataTable dataTable)
{
foreach (DataRow row in dataTable.Rows)
{
allRows.Add(row);
}
}
// 创建一个集合来存储选中的数据
List<DataRow> selectedRows = new List<DataRow>();
// 将选中的数据存储到 selectedRows 集合中
foreach (string selectedRowId in guid_one.SelectedRowIDs)
{
var selectedRowData = guid_one.GetItem(selectedRowId, out var errMsg) as DataRow;
if (selectedRowData != null)
{
selectedRows.Add(selectedRowData);
}
} // 从 allRows 集合中移除 selectedRows 集合中的数据
foreach (var rowToRemove in selectedRows)
{
if (rowToRemove["Id"].ToString() != "0" && !string.IsNullOrEmpty(rowToRemove["Id"].ToString()))
{
allRows.RemoveAll(row => row["Id"].ToString() == rowToRemove["Id"].ToString());
}
}
// 将更新后的数据重新赋值给 guid_one 控件
guid_one.Data = ConvertListToDataTable(allRows);
foreach (string selectedRowId in guid_one.SelectedRowIDs)
{
guid_one.BoundContext.SelectRow(selectedRowId, false);
}
}
private DataTable ConvertListToDataTable(List<DataRow> rows)
{
if (rows == null || rows.Count == 0) {
return new DataTable();
}
DataTable dt = rows[0].Table.Clone(); // 复制表结构
foreach (DataRow row in rows) {
dt.ImportRow(row);
} return dt;
}
标签:控件,rows,清掉,Camstar,List,foreach,guid,allRows,row
From: https://www.cnblogs.com/yxle/p/18323674