获取中继器内从单选按钮选定的单选按钮列表值 [英] Get selected radio button list value from radio buttons inside a Repeater

查看:670
本文介绍了获取中继器内从单选按钮选定的单选按钮列表值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个中继器内的单选按钮列表。我显示的是什么,这看起来像一个屏幕截图。我有中继器的头部模板中的列标题。在项目模板,我有4个字段/列。第3场是一个单选按钮列表。如果,例如,我选择测试任务2行中的是单选按钮 - 我需要回发并保存记录(回数据库)的值。我的中继器可能显示字段和单选按钮列表的多行。

I have a radiobuttonlist inside a repeater. I am showing a screenshot of what this looks like. I have column headers inside the header template of the repeater. In the item template, I have the 4 fields/columns. The 3rd field is a radio button list. If, for example, I select the "Yes" radio button in the "Test Task 2" row - I need to postback and save the value of that record (back to a database). My repeater could potentially display many rows of fields and radio button lists.

推荐答案

试试这个



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;
            }
        }
    }

这篇关于获取中继器内从单选按钮选定的单选按钮列表值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆