简体   繁体   English

如何知道隐藏代码中的选定单选按钮

[英]How To Know Selected Radio Button in Codebehind

I Have A grid view with 3 radio buttons. 我有一个带有3个单选按钮的网格视图。 How Can I Know Which Radio Button Is Selected> 我如何知道选择了哪个单选按钮>

Code: 码:

Please give a try 请尝试一下

foreach (GridViewRow row in gridview.Rows)
{
    RadioButton radioBtn=new RadioButton();
    radioBtn=(RadioButton)row.findcontrol("YourRadiobuttonId");
    if(radioBtn.Checked)
    {
        // Your appropriate code here
    }

}

Try this. 尝试这个。

foreach (GridViewRow row in gridview.Rows)
{
RadioButton rbn=new RadioButton();
rbn=(RadioButton)row.findcontrol("YourRadiobuttonId");
if(rbn.Checked)
 {
    //Try your condition what u want
 }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 知道从代码隐藏中选择了哪个选项卡 - Know which tab is selected from codebehind 如何在数据列表中获取选定的单选按钮文本? - How to get selected radio button text in datalist ? 如何在消息框上显示,选择了哪个单选按钮 - how to display on a messagebox, which radio button was selected 如何更改Windows Phone 8中的选定单选按钮? - How To change Selected Radio Button in windows Phone 8? 如何根据选择的单选按钮在代码隐藏中设置值? - How do you set a value in codebehind depending on which radio button is chosen? 如何在代码隐藏中向按钮添加命令 - How to add a command to the button in codebehind 如何在代码隐藏中引用所选菜单项? - How to reference a selected menu item in codebehind? 如何选中单选按钮以及如何仅控制在列表视图中选择的一个单选按钮 - How to get checked radio button and how to control only one radio button selected in list view 如何在不使用GroupBox的情况下为单选按钮提供值并确定选定的单选按钮 - How can I give a radio button a value and determine the selected radio button without using a GroupBox 如何为 Blazor 服务器中的所有单选按钮存储和显示选定值结果到相应单选按钮 - How To Store And Show Selected Value Result To Respective Radio Button For All Radio Button In Blazor Sever
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM