我将要设置格式的列转化为模板.定义了函数
判断字串里字符个数,并将多余的显示为其他符号,如...
        public static String FirstIndexOf( String input, Int32 Length )
        {
            if( input == null || input == String.Empty )
                return String.Empty;            if( Length <= 0 )
                return input;            Byte [] strBytes = System.Text.Encoding.GetEncoding("GB2312").GetBytes( input );
            if( strBytes.Length <= Length )
                return input;
            else 
            { 
                Byte [] tmpBytes = null;
                if( strBytes[Length] > 127 )       
                    Length++;
                
                tmpBytes = new Byte[Length-3];
                Array.Copy( strBytes, tmpBytes, Length-3 );
                return System.Text.Encoding.GetEncoding("GB2312").GetString(tmpBytes) + "..."; 
            }
}并在前台页里修改代码如下:
<asp:TemplateField HeaderText="维修手记">
  <ItemTemplate>
    <asp:Label ID="Label3" runat="server" Text='<%# FirstIndexOf(Eval("repairdecript"),4)%>' Width="222px"></asp:Label>
  </ItemTemplate>
  <ItemStyle Width="240px" />
  <HeaderStyle Width="240px" />
</asp:TemplateField>但总显示错误
1:与“pcrepair.FirstIndexOf(string, int)”最匹配的重载方法具有一些无效参数
2:参数“1”: 无法从“object”转换为“string” 请问我这么使用有错吗?怎么改正?