最重要的部分共有两处:一个是存储过程,通过fileid把文件名取出来:
CREATE PROCEDURE {databaseOwner}{objectQualifier}GetTopics
(
@ModuleID int
)
AS
SELECT
.
inGuests,
'inImgUrl' = CASE WHEN F.FileName IS NULL THEN A.inImgUrl ELSE F.Folder + F.FileName END
From
TopicsList A
LEFT OUTER JOIN Files F ON A.inImgUrl = 'fileid=' + CONVERT(VARCHAR,F.FileID)
WHERE ModuleID = @ModuleID
RETURN
GO
前面的businesslayer里面的代码如下(
@ModuleID int
)
AS
SELECT
.
inGuests,
'inImgUrl' = CASE WHEN F.FileName IS NULL THEN A.inImgUrl ELSE F.Folder + F.FileName END
From
TopicsList A
LEFT OUTER JOIN Files F ON A.inImgUrl = 'fileid=' + CONVERT(VARCHAR,F.FileID)
WHERE ModuleID = @ModuleID
RETURN
GO
protected string HeaderPic(string s)
{
if( s != "")
{
if( s.StartsWith("http://"))
{
return s;
}
return this.PortalSettings.HomeDirectory.TrimEnd('\\') + "\\" + s;
}
else
{
return "";
}
}
{
if( s != "")
{
if( s.StartsWith("http://"))
{
return s;
}
return this.PortalSettings.HomeDirectory.TrimEnd('\\') + "\\" + s;
}
else
{
return "";
}
}
界面层如下
ImageUrl='<%# HeaderPic(DataBinder.Eval(Container.DataItem, "inImgUrl").ToString()) %>'