如何知道代码背后的选定单选按钮

时间:2012-04-19 15:31:59

标签: c# asp.net gridview code-behind

我有一个带3个单选按钮的网格视图。我如何知道选择哪个单选按钮>

代码:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

2 个答案:

答案 0 :(得分:2)

请试一试

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

}

答案 1 :(得分:1)

试试这个。

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