RadGrid 中的 BLOB 检索
我对使用 Telerik 控件还很陌生,我在 Telerik 论坛上收到的回复为零,但一位朋友推荐了 Stackoverflow,所以我希望有人能提供帮助。
简而言之,我是一名 .NET 程序员,目前正在开发在 DotNetNuke 中使用的模块。对于我当前正在开发的模块,我在 Telerik RadGrid 中显示数据。我的一列包含一个 LinkButton,单击它时需要运行一个函数,从我的数据库中检索 BLOB 并打开 pdf 文件。
我已经使用 GridView 在 .NET 测试环境中进行了此工作。下面是我的 OnClick 事件的代码:
public void lnkWebFileName_Click(object sender, EventArgs e)
{
Label lblWebFileNameNew = (Label)((Control)sender).NamingContainer.FindControl
("lblWebFileName");
string webfilename = lblWebFileNameNew.Text.ToString();
BlobRetrieval.WriteDocumentWithStreaming(webfilename);
}
我没有包含 WriteDocumentWithStreaming 的代码,因为在 .NET 中这就像一个魅力,所以我知道我的检索代码有效。
然而,尝试通过我的 RadGrid 使其正常工作是另一个问题。出于测试目的,我使用以下代码来确保获取 webfilename 值,然后更改按钮文本:
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;
}
完美运行!问题是当我添加:
BlobRetrieval.WriteDocumentWithStreaming(webfilename);
尝试显示 pdf 文件时,它什么也没做。我检查了 DNN 的 EventViewer,收到的唯一错误消息是:
System.Exception: Unhandled Error
有人知道如何通过 RadGrid 检索和显示 BLOB 吗?我是否必须对现有代码做一些特殊的事情,或者 RadGrid 中是否需要做一些特定的事情?
请有人帮助摆脱这个头痛。谢谢你!
MKD
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我的第一个想法是 Telerik 和/或 DNN 将使用部分回发(UpdatePanels),因此您可以尝试使用脚本管理器注册您的 LinkButtons 以避免拥有它们,尝试进行部分回发(当您需要将文件发送给客户端)。您可以通过
DotNetNuke.Framework.AJAX.RegisterPostBackControl
在 DNN 中执行此操作。您还可以尝试将事件处理程序包装在
try
/catch
块中,并调用DotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException
到在事件日志中获取有关异常的更多详细信息。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 callDotNetNuke.Services.Exceptions.Exceptions.ProcessModuleLoadException
to get more details on the exception in the event log.我知道许多 RadGrid 控件依赖于页面上的 RadAjaxManager 以及母版页中的脚本管理器,以便网格执行许多功能。我不确定你的代码中是否有这些。
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.