我有一个方法:
protected string GetName(string sName,int iLength)
{
if(sName.Length <= iLength) 
{
return sName;
}
else
{
return "" +sName.Substring(0,iLength) +"...";
}
}
以前在repeater中用过,现在不知道在DATAGRID中的数据是怎样绑定的

解决方案 »

  1.   

    <%# GetName(数据绑定, 15) %>
      

  2.   

    DATAGRID不支持这样绑定吧,我以前在repeater中是这样绑的,刚才在DATAGRID中试了一下不好用
      

  3.   

    你把protected 改成public应该就可以了。
      

  4.   

    在select里面实现select 沈阳新区开发 + 字段名 from ...
      

  5.   

    <asp:TemplateColumn HeaderText="日工作報告"> 
    <ItemTemplate> 
    <%# SubStr(DataBinder.Eval(Container.DataItem,"repday_body").ToString())%>
    </ItemTemplate> 
    </asp:TemplateColumn>        protected string SubStr(string aa)
    {   aa=Server.UrlDecode(aa);
    if(aa.Length>15)
    {
    aa=aa.Substring(0,15)+"....";
    }
    return aa;
    }