0

我正在尝试下载已检查的 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
}
4

1 回答 1

0

您应该按照以下方式做一些事情:

data.add(manager.GetSearchResultForAssignedProductImageMap1(ImId, CompanyId, brandid));

代替 :

data = manager.GetSearchResultForAssignedProductImageMap1(ImId, CompanyId, brandid);

使用您的代码,您data每次找到一个值时都会覆盖该变量。您需要添加到值列表而不是覆盖它。

于 2013-10-24T08:30:56.573 回答