在.AspX 怎么显示不出来我调用的信息?

Tadpole0510 2011-10-21 10:16:05
在.CS中

public string GetFilePath(int wordID)
{
string filePath = string.Empty;

filePath = Server.UrlEncode(Convert.ToString(SqlHelper.ExecuteScalar(SqlHelper.LocalSqlServer, "select ExpertAuditFile from EditorDistributionWord where wordid=" + wordID)));


return filePath;
}

//mutiExpertID 是数组 例如:134,123,221, 对应的名 张三,李四,王二,
public string GetMutiFilePath(string mutiExpertID,string mutiExpertName)
{

string[] subid = mutiExpertID.Split(',');
string[] subname = mutiExpertName.Split(',');
string _name = string.Empty;
for (int i = 0; i < subid.Length; i++)
{
if (_name != string.Empty)
{

_name += "  <a href=downfile.aspx?FileName=" + Server.UrlEncode("审稿单") + "&FilePath=" + GetFilePath(Convert.ToInt32(subid[i])) + ">" + subname[i] + "</a>";

}

_name= Server.UrlEncode(_name);

}
return _name;

}

.AspX

<asp:TemplateField HeaderText="审稿单" SortExpression="IsState" ItemStyle-HorizontalAlign="center">
<ItemTemplate>

<%# GetMutiFilePath(Eval("SendExpertID").ToString(), Eval("SendExpert").ToString())%>

<a href="downfile.aspx?FileName=<%# Server.UrlEncode("审稿单") %>&FilePath=<%# GetFilePath(Convert.ToInt32(Eval("ID"))) %>">下载</a>

</ItemTemplate>
</asp:TemplateField>


我这么用
<%# GetMutiFilePath(Eval("SendExpertID").ToString(), Eval("SendExpert").ToString())%>
怎么显示不了我想要的链接
...全文
86 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
孟子E章 2011-10-21
  • 打赏
  • 举报
回复
这样简单的问题,你应该学会调试

最简单的调试方法,是把函数改成
public string GetMutiFilePath(string mutiExpertID,string mutiExpertName)
{
return "出来了吗?";
}

这样调试,如果出来了内容,则说明函数的问题。再去一步一步去调试
public string GetMutiFilePath(string mutiExpertID,string mutiExpertName)
{
return mutiExpertID + "||" + mutiExpertName;
}

如果出来了内容,则添加别的代码
孟子E章 2011-10-21
  • 打赏
  • 举报
回复
_name += "  <a href=downfile.aspx?FileName=" + Server.UrlEncode("审稿单") + "&FilePath=" + subid[i] + ">" + subname[i] + "</a>";
改成这样呢?
你保证 subid[i] 都是数字??
Tadpole0510 2011-10-21
  • 打赏
  • 举报
回复
输入字符串的格式不正确。

_name += "  <a href=downfile.aspx?FileName=" + Server.UrlEncode("审稿单") + "&FilePath=" + GetFilePath(Convert.ToInt32(subid[i])) + ">" + subname[i] + "</a>";

也没有错哦

Tadpole0510 2011-10-21
  • 打赏
  • 举报
回复
to : zell419
不行 不显示



<a href="downfile.aspx?FileName=<%# Server.UrlEncode("审稿单") %>&FilePath=<%# GetFilePath(Convert.ToInt32(Eval("ID"))) %>">下载</a>
只能显示一个


我想显示参数 专家名 并且有链接 能下载

孟子E章 2011-10-21
  • 打赏
  • 举报
回复
另外,保证你的GetFilePath方法也没有问题。你可以

public string GetFilePath(int wordID)
{

return "test";
}

先使用假设的数据进行测试
suokei 2011-10-21
  • 打赏
  • 举报
回复
你把_name = string.Empty;

又判断if (_name != string.Empty)

这样肯定不会有值的,自己可以跟踪一下代码就找到问题了。
孟子E章 2011-10-21
  • 打赏
  • 举报
回复
public string GetMutiFilePath(string mutiExpertID,string mutiExpertName)
{

string[] subid = mutiExpertID.Split(',');
string[] subname = mutiExpertName.Split(',');
string _name = string.Empty;
for (int i = 0; i < subid.Length; i++)
{


_name += "  <a href=downfile.aspx?FileName=" + Server.UrlEncode("审稿单") + "&FilePath=" + GetFilePath(Convert.ToInt32(subid[i])) + ">" + subname[i] + "</a>";


}
return _name;

}
Tadpole0510 2011-10-21
  • 打赏
  • 举报
回复
我一点击张三 或者李四 或者王二 可以另存为文件下载
zell419 2011-10-21
  • 打赏
  • 举报
回复
进入了后台方法没有 。
<%#GetMutiFilePath(Convert.ToString(DataBinder.Eval(Container.DataItem, "SendExpertID")))%>
这样试试 。
孟子E章 2011-10-21
  • 打赏
  • 举报
回复
string _name = string.Empty;
for (int i = 0; i < subid.Length; i++)
{
if (_name != string.Empty)
{

你这个判断也有问题

_name开始是 string.Empty,里面的代码永远不执行了
去掉
if (_name != string.Empty)
Tadpole0510 2011-10-21
  • 打赏
  • 举报
回复
我想显示 张三,李四,王二 链接的下载
孟子E章 2011-10-21
  • 打赏
  • 举报
回复
_name= Server.UrlEncode(_name);
没有必要Server.UrlEncode

另外,你显示出的是什么内容?

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧