首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > asp.net >

substr异常,GridVeiw如何显示content属性的前20个字符

2012-03-09 
substr错误,GridVeiw怎么显示content属性的前20个字符。前台asp:TemplateField HeaderText回复内容It

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, 

热点排行