当前位置:编程学习 > C#/ASP.NET >>

reapeat控件怎么取值

请问 reapeat控件 里面的控件的值 我要怎么得啊

比如 得到 RadioButtonList是否被选择 得到每一行的ID

能具体的说下思路吗~~~  

麻烦大家了~~ --------------------编程问答--------------------
foreach(RepeaterItem item in Repeater1.Items)
            {
                 RadioButtonList p=item.FindControl("RadioButtonList1") as RadioButtonList;
                
            }
--------------------编程问答--------------------
引用 1 楼 q107770540 的回复:
C# code
foreach(RepeaterItem item in Repeater1.Items)
            {
                 RadioButtonList p=item.FindControl("RadioButtonList1") as RadioButtonList;
                
            }

对  控件里面找控件 --------------------编程问答--------------------

for(int i=0;i<Repeater1.Items.Count;i++)
{
 RadioButtonList p=(RadioButtonList)Repeater1.Items[i].FindControl("RadioButtonList1"); 
}

这样也可以 --------------------编程问答-------------------- 哇 冒失大家的都是正解啊

这些 代码 我应该在哪个事件里面处发了  --------------------编程问答--------------------
引用 4 楼 weiwei7v8v 的回复:
哇 冒失大家的都是正解啊

这些 代码 我应该在哪个事件里面处发了

哪儿都行,比如button的click事件,放里面就可以 --------------------编程问答-------------------- 是写在ItemDataBound事件里面吗 --------------------编程问答-------------------- 哦 原来如此  --------------------编程问答--------------------
引用 6 楼 weiwei7v8v 的回复:
是写在ItemDataBound事件里面吗

不用,看你需求了。放ItemDataBound事件里面是需要在数据绑定的时候做处理。
主要的步骤就是 使用findcontrol方法找到这个控件,然后进一步操作 --------------------编程问答-------------------- 我用了这种 

for(int i=0;i<Repeater1.Items.Count;i++)
{
 RadioButtonList p=(RadioButtonList)Repeater1.Items[i].FindControl("RadioButtonList1"); 
}
这个循环 不进 括号里面的语句这是怎么回事?

为什么还是得不到值啊  radioButtonList 取值是 SelectedValue 吧
补充:.NET技术 ,  ASP.NET
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,