永发信息网

在Repeater中循环遍历input的值

答案:2  悬赏:20  手机版
解决时间 2021-02-25 10:04
  • 提问者网友:星軌
  • 2021-02-24 21:26
在Repeater中循环遍历input的值,为什么exceptions会为空?
如果想保存在String name中改如何保存?
前台:

" />

for (int i = 0; i < rptList.Items.Count; i++)
{
HtmlInputText txt_exceptions = (HtmlInputText)rptList.Items[i].FindControl("txt_name");
}
最佳答案
  • 五星知识达人网友:舊物识亽
  • 2021-02-24 21:52
额。。是不是因为你input标签设置了ID,然后repeater的话,id重复,无法获取准确的标签,导致出现bug
全部回答
  • 1楼网友:痴妹与他
  • 2021-02-24 22:28
repeater2 数据源查询的一个条件值 是repeater1的一个值,这个值是跟repeater2 在同一行的吗? 如果是的话可以使用repeater1的itemdatabound事件来绑定 protected voidrepeater1_itemdatabound(object sender, repeateritemeventargs e) { if (e.item.itemtype == listitemtype.item || e.item.itemtype == listitemtype.alternatingitem) { label lbljobcategoryid = e.item.findcontrol("lbljobcategoryid") as label; label lblcategoryname = e.item.findcontrol("lblcategoryname") as label; jobcategory entityjobcategory = new jobcategory(); repeater repeater2= e.item.findcontrol("repeater2") as repeater; var source = entityjobcategory.getjobcategorycontact(lbljobcategoryid.text.toint()); repeater2.datasource = source; repeater2.databind(); } } 如果不是的话只能绑定完repeater1之后遍历整个repeater1 foreach (gridviewrow gdrow in repeater1.rows) { label lbljobcategoryid = gdrow.findcontrol("lbljobcategoryid") as label; label lblcategoryname = gdrow.findcontrol("lblcategoryname") as label; jobcategory entityjobcategory = new jobcategory(); repeater repeater2= gdrow.findcontrol("repeater2") as repeater; var source = entityjobcategory.getjobcategorycontact(lbljobcategoryid.text.toint()); repeater2.datasource = source; repeater2.databind(); }
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯