//前台代码:(绑定数据库字段)
//后台代码:得到repeater显示的数据(遍例)
后记:
string id= "";
for (int i = 0; i < this.Repeater1.Items.Count; i++)
{
Label lbid= (Label)this.Repeater1.Items[i].FindControl("lbid");
id= id.Text;
}
repeater控件中包含标签lbid(Label)等控件,可通过以上方法得到其实绑定的值!
CSDN论坛内容:
GridView,Repeater,DataList中查找控件要遍历一下才可以
GridView:
for(int i=0; i <GridView.Rows.Count;i++)
{
Label lbl = (Label)GridView.Rows[i].FindControl("Label");
}
Repeater:
for(int i=0; i < Repeater.Items.Count;i++)
{
Label lbl = (Label) Repeater.Items[i].FindControl("Label");
}
DataList:
for(int i=0; i < DataList.Items.Count;i++)
{
Label lbl = (Label) DataList.Items[i].FindControl("Label");
}