在.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 += "&nbsp;&nbsp;<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())%> 
怎么显示不了我想要的链接

解决方案 »

  1.   

    _name= Server.UrlEncode(_name);
    没有必要Server.UrlEncode另外,你显示出的是什么内容?
      

  2.   

    string _name = string.Empty;
      for (int i = 0; i < subid.Length; i++)
      {
      if (_name != string.Empty)
      {你这个判断也有问题 _name开始是 string.Empty,里面的代码永远不执行了
    去掉
      if (_name != string.Empty)
      

  3.   

    进入了后台方法没有 。
    <%#GetMutiFilePath(Convert.ToString(DataBinder.Eval(Container.DataItem, "SendExpertID")))%>
    这样试试 。
      

  4.   

    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 += "&nbsp;&nbsp;<a href=downfile.aspx?FileName=" + Server.UrlEncode("审稿单") + "&FilePath=" + GetFilePath(Convert.ToInt32(subid[i])) + ">" + subname[i] + "</a>";   
      }
      return _name;
     
      }
      

  5.   

    你把_name = string.Empty;又判断if (_name != string.Empty)这样肯定不会有值的,自己可以跟踪一下代码就找到问题了。
      

  6.   

    另外,保证你的GetFilePath方法也没有问题。你可以public string GetFilePath(int wordID)
      { 
     
      return "test";
      }先使用假设的数据进行测试
      

  7.   

    to : zell419 
    不行 不显示<a href="downfile.aspx?FileName=<%# Server.UrlEncode("审稿单") %>&FilePath=<%# GetFilePath(Convert.ToInt32(Eval("ID"))) %>">下载</a>
    只能显示一个
    我想显示参数 专家名 并且有链接  能下载
      

  8.   

    输入字符串的格式不正确。 _name += "&nbsp;&nbsp;<a href=downfile.aspx?FileName=" + Server.UrlEncode("审稿单") + "&FilePath=" + GetFilePath(Convert.ToInt32(subid[i])) + ">" + subname[i] + "</a>";也没有错哦
      

  9.   

    _name += "&nbsp;&nbsp;<a href=downfile.aspx?FileName=" + Server.UrlEncode("审稿单") + "&FilePath=" + subid[i] + ">" + subname[i] + "</a>";
    改成这样呢?
    你保证 subid[i] 都是数字??
      

  10.   

    这样简单的问题,你应该学会调试最简单的调试方法,是把函数改成
    public string GetMutiFilePath(string mutiExpertID,string mutiExpertName)
    {
     return "出来了吗?";
    }这样调试,如果出来了内容,则说明函数的问题。再去一步一步去调试
    public string GetMutiFilePath(string mutiExpertID,string mutiExpertName)
    {
     return mutiExpertID + "||" + mutiExpertName;
    }如果出来了内容,则添加别的代码