asp.net中继器 - 获取行项目的价值_DataBound [英] asp.net repeater - get value of row item _DataBound
本文介绍了asp.net中继器 - 获取行项目的价值_DataBound的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能得到我想要在一个中继器_DataBound子每个单元格的值? - 这是这样我就可以更改值一点,将更改应用于文字
how can I get the value of each cell that I want in a repeater _DataBound sub? - this is so I can change the value a little and apply the change to a literal
推荐答案
让我们说这是你的中继器(因为你没有包含任何code):
Let's say this is your repeater (since you didn't include any code):
<asp:Repeater ID="_r" runat="server">
<ItemTemplate>
<asp:Literal ID="_lit" Text='<%# Eval("yourItemName")%>' runat="server"></asp:Literal>
<br /><br />
</ItemTemplate>
</asp:Repeater>
和因为要喵添加到每一个文字(否则将只显示的ItemDataBound
事件> yourItemName )
and you make an ItemDataBound
event because you want to add "meow" to the end of every literal (which otherwise will just show the value of yourItemName
from the datasource):
protected void Page_Load(object sender, EventArgs e)
{
_r.DataSource = table;
_r.ItemDataBound += new RepeaterItemEventHandler(RItemDataBound);
_r.DataBind();
}
protected void RItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Literal lit = (Literal)e.Item.FindControl("_lit");
lit.Text += "meow";
}
}
这篇关于asp.net中继器 - 获取行项目的价值_DataBound的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文