我有一个表单,它搜索在日期范围之间发生的单个表(TServices)中的所有行,然后在表单下方填充一个动态表。
现在我在表中的每个列表旁边添加一个删除 ImageButton。这是我的 C# 代码隐藏,用于将 ImageButtons 添加到表格单元格:
ImageButton btnRemoveService = new ImageButton();
btnRemoveService.EnableViewState = true;
btnRemoveService.ImageUrl = "/images/icons/trash.gif";
btnRemoveService.Click += new ImageClickEventHandler(btnRemoveService_Click);
btnRemoveService.ID = "btnRemoveService-" + row["BillingID"].ToString();
btnRemoveService.CommandArgument = row["BillingID"].ToString();
tblCell.Controls.Add(btnRemoveService);
即使我没有在 btnRemoveService_Click() 中添加任何内容,动态表中的所有数据也会消失。当我输入代码以实际删除存储过程时,数据从动态表中消失,数据库中没有任何变化。
编辑: 我将填充代码移动到它自己的函数中,并在 btnRemoveService_Click() 的末尾调用它。这不应该重新加载数据吗?