关于ItemTemplate内的内容。

billy_zh 2004-04-23 10:15:17
一般ItemTemplate内的内容是:
<itemtemplate>
<%# ... %>
</itemtemplate>

能不能用这种形式的方法来显示数据:
<itemtemplate>
<asp:label id="lbltest" runat="server">
</itemtemplate>
然后在后置代码中对label进行数据绑定?
...全文
74 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
saucer 2004-04-25
  • 打赏
  • 举报
回复
override ItemDataBound Event handler, inside it, do

if (e.Item.ItemType == ListItemType.Item ||
e.Item.ItemType == ListItemType.AlternatingItem)
{

Label lbl = (Label)e.Item.FindControl("lbltest");
lbl.Text = "123";
lbl.Text = DataBinder.Eval(e.Item.DataItem,"Column1").ToString();
}
billy_zh 2004-04-25
  • 打赏
  • 举报
回复
楼上的回答与我提的问题不符!
我是问有没办法在代码后置文件(cs文件)中进行绑定?
billy_zh 2004-04-25
  • 打赏
  • 举报
回复
谢谢思归老大!
smoothwood 2004-04-23
  • 打赏
  • 举报
回复
<asp:TemplateColumn><ItemTemplate><asp:label id="lbltest" runat="server" text='<%#...%>'></asp:Label></ItemTemplate></asp:TemplateColumn>

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧