gridview的temple中调用后台函数,哪里出错了?提示没这个函数
我gridview的temple列如下:
<asp:TemplateField ItemStyle-Height = "150" ItemStyle-Width = "170">
<ItemTemplate>
<asp:Image ID="Image1" runat="server"
ImageUrl = '<%# Eval("FilePath", GetUrl("{0}")) %>' />
</ItemTemplate>
</asp:TemplateField>
后台代码是:
C# code
public string GetUrl(string imagepath)
{
string[] splits = Request.Url.AbsoluteUri.Split('/');
if (splits.Length >= 2)
{
string url = splits[0] + "//";
for (int i = 2; i < splits.Length - 1; i++)
{
url += splits[i];
url += "/";
}
return url + imagepath;
}
return imagepath;
}
运行后,系统提示Compiler Error Message: CS0103: The name 'GetUrl' does not exist in the current context
------解决方案--------------------文件名对了吗
------解决方案--------------------调用方式错了
ImageUrl = '<%# GetUrl(Eval("FilePath").ToString()) %>' />