怎么遍历repeater行, 如题 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 GridView,DataList,Repeater,DetailsView的遍历行代码 for(int i =0;int i<repeater1.row.Count i++){ reperter1.Count[i]....}手敲的 可能有点失误 不过你自己好好看下应该能解决 没办法和gridview那样遍历,要看你repeater里面具体是如何绑定的. 这个好像是不行吧 只有看你里面杂绑定的了!也可以在它里面套一个gridview for(int i =0;int i<repeater1.row.Count i++){ reperter1.Count[i]....} for (int i = 0; i < this.Reapter1.Items.Count; i++) { //CheckBox cb = this.rpLink.Items[i].FindControl("cbChild") as CheckBox; //HiddenField hf = this.rpLink.Items[i].FindControl("hf") as HiddenField; //if (cb != null && cb.Checked && hf != null) //{ // modifyInfo(Convert.ToInt32(hf.Value)); //} } RepeaterItemCollection rtc = this.Repeater1.Items; foreach(RepeaterItem item in rtc) { }这样遍历吧 <a href="www.baidu.com"></a> foreach(RepeaterItem items in repeater1.Items){}orfor(int i=0;i<Repeater1.ItemsCount-1;i++){} this.NewGameRoom.DataSource = GameRooms; this.NewGameRoom.ItemDataBound += new RepeaterItemEventHandler(NewGameRoom_ItemDataBound); this.NewGameRoom.DataBind();这是绑定语句撒,里面不是有个this.NewGameRoom.ItemDataBound += new RepeaterItemEventHandler(NewGameRoom_ItemDataBound);这一句就是用来遍历的,如果只要数据绑定行void NewGameRoom_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { KeyValuePair<ushort, string> key = (KeyValuePair<ushort, string>)e.Item.DataItem; Literal nickname = e.Item.FindControl("nickname") as Literal; Literal small_blind = e.Item.FindControl("small_blind") as Literal; Literal big_blind = e.Item.FindControl("big_blind") as Literal; Literal user_count = e.Item.FindControl("user_count") as Literal; Literal user_max = e.Item.FindControl("user_max") as Literal; nickname.Text = roomdic[key.Key]["nickname"]; small_blind.Text = roomdic[key.Key]["small_blind"]; big_blind.Text = roomdic[key.Key]["big_blind"]; user_count.Text = roomdic[key.Key]["user_count"]; user_max.Text = roomdic[key.Key]["user_max"]; HyperLink intoGame = e.Item.FindControl("intoGame") as HyperLink; if (GlobalVariable.GameLimite() == 1) { intoGame.Attributes.Add("onclick", string.Format("javascript:PlayGame('{0}',Right.IsGame('{1}',{2}),'{3}');", key.Key.ToString().DESEncrypt(), _User.GetUserTicket().UID.ToString(), 1, key.Key.ToString())); } else { intoGame.Attributes.Add("onclick", string.Format("javascript:PlayGame('{0}',Right.IsRoom('{1}',{2}),'{3}');", key.Key.ToString().DESEncrypt(), _User.GetUserTicket().UID.ToString(), key.Key.ToString(), key.Key.ToString())); } } }最开始的这句if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)就是用来判断是那种类型的行,有header,foot,如果不要这句,就是遍历所有的行 foreach(RepeaterItem item in Rp1.Items){} if (this.rptTypes.Items.Count != null && this.rptTypes.Items.Count > 0) { foreach (RepeaterItem item in this.rptTypes.Items) { Common.ProcessWrite.WriteDialog(item.Index.ToString()); } } ASP.NET网站部署问题:HttpModule部署后不起作用 上传文件是报未找到路径的一部分,请教 插件调试时能起作用,但是放在服务器上却不行。 如何取出datagrid中的记录 BindDropdownlist 如何使用数据库连接类???? vbscript的一个问题 如何获取aspx文件中runat="server"的控件信息? 关于form验证的问题 在window Form中的datagrid重新绑定数据的问题,希望“思归”等高手相助!! 导入导出 求助,如何修改asp内页的title?????
for(int i =0;int i<repeater1.row.Count i++)
{
reperter1.Count[i]....
}手敲的 可能有点失误 不过你自己好好看下应该能解决
只有看你里面杂绑定的了!
也可以在它里面套一个gridview
{
reperter1.Count[i]....
}
{
//CheckBox cb = this.rpLink.Items[i].FindControl("cbChild") as CheckBox;
//HiddenField hf = this.rpLink.Items[i].FindControl("hf") as HiddenField;
//if (cb != null && cb.Checked && hf != null)
//{
// modifyInfo(Convert.ToInt32(hf.Value)); //}
}
RepeaterItemCollection rtc = this.Repeater1.Items;
foreach(RepeaterItem item in rtc)
{
}这样遍历吧
or
for(int i=0;i<Repeater1.ItemsCount-1;i++){}
this.NewGameRoom.ItemDataBound += new RepeaterItemEventHandler(NewGameRoom_ItemDataBound);
this.NewGameRoom.DataBind();
这是绑定语句撒,里面不是有个this.NewGameRoom.ItemDataBound += new RepeaterItemEventHandler(NewGameRoom_ItemDataBound);
这一句就是用来遍历的,如果只要数据绑定行
void NewGameRoom_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)
{
KeyValuePair<ushort, string> key = (KeyValuePair<ushort, string>)e.Item.DataItem;
Literal nickname = e.Item.FindControl("nickname") as Literal;
Literal small_blind = e.Item.FindControl("small_blind") as Literal;
Literal big_blind = e.Item.FindControl("big_blind") as Literal;
Literal user_count = e.Item.FindControl("user_count") as Literal;
Literal user_max = e.Item.FindControl("user_max") as Literal; nickname.Text = roomdic[key.Key]["nickname"];
small_blind.Text = roomdic[key.Key]["small_blind"];
big_blind.Text = roomdic[key.Key]["big_blind"];
user_count.Text = roomdic[key.Key]["user_count"];
user_max.Text = roomdic[key.Key]["user_max"]; HyperLink intoGame = e.Item.FindControl("intoGame") as HyperLink;
if (GlobalVariable.GameLimite() == 1)
{
intoGame.Attributes.Add("onclick", string.Format("javascript:PlayGame('{0}',Right.IsGame('{1}',{2}),'{3}');", key.Key.ToString().DESEncrypt(), _User.GetUserTicket().UID.ToString(), 1, key.Key.ToString()));
}
else
{
intoGame.Attributes.Add("onclick", string.Format("javascript:PlayGame('{0}',Right.IsRoom('{1}',{2}),'{3}');", key.Key.ToString().DESEncrypt(), _User.GetUserTicket().UID.ToString(), key.Key.ToString(), key.Key.ToString()));
}
}
}
最开始的这句
if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item)就是用来判断是那种类型的行,有header,foot,如果不要这句,就是遍历所有的行
foreach(RepeaterItem item in Rp1.Items)
{}
{
foreach (RepeaterItem item in this.rptTypes.Items)
{
Common.ProcessWrite.WriteDialog(item.Index.ToString());
}
}