检查来自datalist的单选按钮值?

时间:2013-08-23 06:07:40

标签: asp.net

我想提出一些带有多选单选按钮的数据列表视图的问题,以便如何从列表中获取每个问题的答案或检查单选按钮值?

1 个答案:

答案 0 :(得分:0)

enter image description here

protected void btnSave_Click(object sender, EventArgs e)
        {
            foreach (RepeaterItem item in Repeater1.Items)
            {
                // Checking the item is a data item
                if (item.ItemType == ListItemType.Item || item.ItemType == ListItemType.AlternatingItem)
                {
                    var rdbList = item.FindControl("RadioButtonList1") as RadioButtonList;
                    // Get the selected value
                    string selected = rdbList.SelectedValue;
                }
            }
        }

试试这个让我知道