开发者

BLOB Retrieval in RadGrid

开发者 https://www.devze.com 2023-03-25 15:32 出处:网络
I\'m pretty new to working with Telerik controls, and I\'ve received zero response on the Telerik forums in regard to this, but a friend recommended Stackoverflow, so I hope someone can help.

I'm pretty new to working with Telerik controls, and I've received zero response on the Telerik forums in regard to this, but a friend recommended Stackoverflow, so I hope someone can help.

In short, I'm a .NET programmer who is currently developing modules for use within DotNetNuke. For the module I'm currently working on, I'm displaying data in a Telerik RadGrid. One of my columns contains a LinkButton which when it's clicked needs to run a function that retrieves a BLOB from my database and opens the pdf file.

I've got this working within a .NET test environment using a GridView. Here's the code for my OnClick event:

public void lnkWebFileName_Click(object sender, EventArgs e)
{
   Label lblWebFileNameNew = (Label)((Control)sender).NamingContainer.FindControl
   ("lblWebFileName");
   string webfilename = lblWebFileNameNew.Text.ToString();
   BlobRetrieval.WriteDocumentWithStreaming(webfilename);
}

I haven't included the code for WriteDocumentWithStreaming because in .NET this works like a charm, so I know my retrieval code works.

Trying to get this to work via my RadGrid, however, is another issue. For testing purposes, I use the following code to make sure I'm getting the webfilename value and then I change the button text:

public void lnkWebFileName_Click(object sender, EventArgs e)
{
   Label lblWebFileNameNew = (Label)((Control)sender).NamingContainer.FindControl  
   ("lblWebFileName");
   LinkButton lnkBtn = (LinkButton)((Control)sender).NamingContainer.FindControl
   ("lnkWebFileName");
   string webfilename = lblWebFileNameNew.Text.ToString();
   lnkBtn.Text = webfilename;
}

Works perfectly! The problem is when I add:

BlobRetrieval.WriteDocumentWithStreaming(webfilename);

to try to display the pdf file, it does nothing. I checked DNN's EventViewer, and the only error message I get is:

System.Exception: Unhandled Error

Does anybody have any idea what to do to retrieve and display a BLOB via a RadGrid? Do I have 开发者_开发知识库to do something special with my existing code, or is there something specific within RadGrid that needs to be done?

Someone please help get rid of this headache. Thank you!

MKDnn


My first thought would be that Telerik and/or DNN are going to be using partial postbacks (UpdatePanels), so you might try registering your LinkButtons with the script manager to avoid having them, try to do partial postbacks (which won't work when you need to send a file down to the client). You can do this in DNN via DotNetNuke.Framework.AJAX.RegisterPostBackControl.

You can also try wrapping your event handler in a try/catch block, and call DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException to get more details on the exception in the event log.


I know that a lot of RadGrid controls rely on a RadAjaxManager on the page as well as a script manager in the masterpage for the grid to do a lot of its functionality. I am not sure if you have these in your code or not.

    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="ConfigurationPanel1">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="containerDiv" LoadingPanelID="RadAjaxLoadingPanel1"></telerik:AjaxUpdatedControl>
                <telerik:AjaxUpdatedControl ControlID="ConfigurationPanel1"></telerik:AjaxUpdatedControl>
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号