OnClientClick='<%#Eval("resume_id", "getName(\"{0}\")")%>'
repeater绑定数据时,如果要针对列值做处理,有两方式:
1 OnItemDataBound="Repeater2_ItemDataBound"
在列中间加一个label来存放数据,然后在行中查这个label控制,再处理赋值
<td> <asp:Label runat="server" ID="label" Text="Label"> </asp:Label></td>
protected void Repeater2_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Label label = (Label)e.Item.FindControl("label");
string textBefore = ((LotCommerce.Biz.MarketProductRow)(e.Item.DataItem)).Brief;
string textAfter = ((!String.IsNullOrEmpty(textBefore) && textBefore.Length > 50) ? Lottery.Tool.StringHelper.SafeSubString(textBefore, 50) + "..." : (Lottery.Tool.StringHelper.SafeSubString(textBefore, 50)));
label.Text = textAfter;
}
}
2 使用DataBinder.Eval(Container.DataItem,"XXX"),再在外面套用函数,例如
<td> <%# StringHelper.SafeSubString( Eval("Brief"),5) %></td>