我正在尝试下载已检查的gridview记录。 Gridview包含图像和数据。数据将在Excel工作表中下载。问题是当我检查要下载的griview的记录时。仅下载最后检查的记录。所有都没有下载。我想我应该使用一个数组。但请帮我这样做:
BubnaManager manager = new BubnaManager();
int count = GridAssigned.Rows.Count;
var data = (List<ProductImageMapWrapper>)null;
for (int i = 0; i < count; i++)
{
HiddenField ImageId = GridAssigned.Rows[i].FindControl("hdn_id2") as HiddenField;
int ImId = Convert.ToInt32(ImageId.Value);
CheckBox chkIDLabel = GridAssigned.Rows[i].FindControl("NewCheckBoxImage") as CheckBox;
if (chkIDLabel.Checked == true)
{
TextBox txtCompany = GridAssigned.Rows[i].FindControl("TextBoxCompany") as TextBox;
TextBox txtBrand = GridAssigned.Rows[i].FindControl("TextBoxBrand") as TextBox;
HiddenField hdBrand = GridAssigned.Rows[i].FindControl("newhdBrand") as HiddenField;
HiddenField hdCompany = GridAssigned.Rows[i].FindControl("newhdCompany") as HiddenField;
int brandid = bm.getIdbyBrand(txtBrand.Text);
int CompanyId = bm.getIdbyCompany(txtCompany.Text);
data = manager.GetSearchResultForAssignedProductImageMap1(ImId, CompanyId, brandid);
}
}
if(data.count!=0)
{
// code for downloading
}
答案 0 :(得分:0)
你应该按照以下方式做点什么:
data.add(manager.GetSearchResultForAssignedProductImageMap1(ImId, CompanyId, brandid));
而不是:
data = manager.GetSearchResultForAssignedProductImageMap1(ImId, CompanyId, brandid);
使用您的代码,每次找到值时都会覆盖data
变量。您需要添加到值列表而不是覆盖它。