http://blog.csdn.net/woailaji1/article/details/4088957
我们以Repeater为例:
1.首先在Repeater中<ItemTemplate>里加入一个服务器控件Label
2.通常情况下在Label中显示字段所用的方法是
<asp:Label runat="server" Text='<%# Eval("Client_Name")%>' />
其中Client_Name是要显示的数据表的字段名
3.然后对Client_Name加入逻辑
<asp:Label runat="server" Text='<%# Method(Eval("Client_Name").ToString().Trim())%>' />
其中Method是后台要手写的方法名,最好加上ToString().Trim()否则总报错
4.在后台随意写Method的内容,让这个方法返回我们所要显示的字段的内容。
比如:public string Method(string Client_Name)
{
//逻辑内容
Return //返回需要显示的内容
}
为GridView,DataList,Repeater中显示的字段加入逻辑
猜你喜欢
转载自darkwingboy.iteye.com/blog/1469073
今日推荐
周排行