程序园

弹奏键盘人生,拂去青春的尘土,留下的只有岁月的痕迹
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

GridView中模拟RadioButton组代码

Posted on 2008-09-04 11:10  程旭圆  阅读(214)  评论(0)    收藏  举报

protected void grb_customerID_CheckedChanged(object sender, EventArgs e)
    {
        //清除GridView中所有RadioButton的选中状态
        foreach (GridViewRow oldrow in gv_customerInfo.Rows)
        {
            ((RadioButton)oldrow.FindControl("grb_customerID")).Checked = false;
        }
        //查找当前行的RadioButton并将其Checked 状态设置为true

        RadioButton rb = (RadioButton)sender;
        GridViewRow row = (GridViewRow)rb.NamingContainer;
        ((RadioButton)row.FindControl("grb_customerID")).Checked = true;
    }