repeater 页面截取控制字符长度
后台:
public string GetString(string str, int length)
{
if (str.Length > length)
return str = str.Substring(0, length);
else
return str;
}
前台:
<asp:Repeater runat="server" ID="repeater_list" OnItemDataBound="repeater_list_ItemDataBound">
<ItemTemplate>
<tr onmouseover='setcolorup(this);' onmouseout='setcolordown(this);' onclick="rowcheck(this)"
ondblclick="document.location.href='fo01view.aspx?TeachId=<%#Eval("TECHACCEPT_ID")%>';">
<td>
<%#Eval("IDEN_STATE_NAME")%>
</td>
<td>
<%#Eval("FINACE_STATE_NAME")%>
</td>
<td>
<%#Eval("TECHACCEPT_NO")%>
</td>
<td>
<%#Eval("FM_CITY")%>
</td>
<td>
<%#Eval("TECHACCEPT_TYPE_NAME")%>
</td>
<td>
<%#Eval("FM_TYPE")%>
</td>
<td>
<%#Eval("FM_CLASS")%>
</td>
<td>
<%#GetString(Eval("ARC_CONCLUSION").ToString(),5)%>
</td>
<td>
<%#Eval("ARC_NAME")%>
</td>
<td>
<%#Eval("IDENT_MAIN")%>
</td>
<td>
<%#Eval("ARC_ASS_NAME")%>
</td>
<td>
<asp:LinkButton ID="LinkBtnDel" OnClientClick="return confirm('确定删除?')" OnClick="linkBtn_Del_Click"
runat="server">删除</asp:LinkButton>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
<%#GetString(Eval("ARC_CONCLUSION").ToString(),5)%>
提示未将对象引用到实例
------解决方案--------------------<%=GetString(Eval("ARC_CONCLUSION").ToString(),5)%>
用=号
------解决方案--------------------C# code
public string GetString(string str, int length)
{
string returnStr = string.Empty;
if (!string.IsNullOrEmpty(str))
{
if (str.Length > length)
returnStr = str.Substring(0, length);
}
return returnStr;
}