日期:2014-05-18  浏览次数:20392 次

substr错误,GridVeiw怎么显示content属性的前20个字符。
前台
<asp:TemplateField HeaderText="回复内容">
<ItemTemplate>
<a href='BbsItemDetail.aspx?item_no=<%# Eval("item_no") %>&User=<%=User%>'>
<asp:Label ID="Label2" runat="server" Text='<%#Eval("substr(itemd_content,1,20)")%>'></asp:Label> </a>
</ItemTemplate>
</asp:TemplateField>
后台
 command.CommandText = "select a.item_no,substr(item_title,1,20),itemd_author, itemd_publishdate, substr(itemd_content,1,20) from th_item a right join th_itemdetail b on a.item_no=b.item_no where itemd_author='" + User + "'";

提示错误为DataBinding:“System.Data.DataRowView”不包含名为“substr”的属性。
我怎样才能在Gridveiw里面显示itemd_content前20个字符。请高手帮忙?
如果是<asp:BoundField DataField="substr(itemd_content,1,20)" />肯定没有问题,但是我现在想把该字段弄成链接。怎么实现。迷茫中,
 

------解决方案--------------------
加个别名
SQL code
substring(itemd_content,1,20) as itemd_content,
left(itemd_content,20) as itemd_content,