UpdatePanel和ListView控件未显示BLOB的数据



我正在尝试从Azure Blob中填充数据(用超链接)。

这是我的代码:

updatePanel:

<asp:UpdatePanel ID="up1" runat="server" UpdateMode="Conditional">
    <ContentTemplate>
        <asp:Button ID="refreshButton" runat="server" Text="Refresh" OnClick="refreshButton_Click" />
        <asp:ListView ID="fileDisplayControl" runat="server">
            <LayoutTemplate>
                <asp:Hyperlink ID="itemPlaceholder" runat="server" />
            </LayoutTemplate>
            <ItemTemplate>
                <asp:Hyperlink ID="filehyperlink" runat="server" NavigateUrl='<%# Eval("Url") %>' /> 
            </ItemTemplate>
        </asp:ListView>
    </ContentTemplate>
</asp:UpdatePanel>

在ListView中,我放置了超链接控件,其中数据填充了超链接。

代码向ListView控件提供数据源:

private CloudBlobContainer getfileGalleryContainer()
{
    return _blobStorageService.getCloudBlobContainer();
}
protected void Page_PreRender(object sender, EventArgs e)
{
    try
    {
        // Blob container that contains the ppp
        // Perform a query of the its contents and return the list of all of the blobs whose name begins with the string "ppp". 
        // It returns an enumerator of their URLs and place that enumerator into list view as its data source. 
        fileDisplayControl.DataSource = 
            from o in getfileGalleryContainer().GetDirectoryReference("ppp").ListBlobs()
            select new { Url = o.Uri };
        // List view to bind to its data source
        fileDisplayControl.DataBind();
    }
    catch (Exception)
    {
    }
}

不幸的是,即使文件存储在ppp blob中。

有人请告诉我这个过程中有什么问题?

您的问题太广泛。您必须逐步检查您的问题是什么:

protected void Page_PreRender(object sender, EventArgs e)
{
    var checkMe1 = _blobStorageService.getCloudBlobContainer();
    var checkMe2 = checkMe1.GetDirectoryReference("ppp");
    var cehckMe3 = checkMe2.ListBlobs();
    var checkMe4 = from o in cehckMe3
                    select new { Url = o.Uri }.ToList();
    fileDisplayControl.DataSource = checkMe4;
    // List view to bind to its data source
    fileDisplayControl.DataBind();
}

最新更新