Jean Claude Abela
Jean Claude Abela

Reputation: 907

How To Know Selected Radio Button in Codebehind

I Have A grid view with 3 radio buttons. How Can I Know Which Radio Button Is Selected>

Code:

Upvotes: 0

Views: 3021

Answers (2)

4b0
4b0

Reputation: 22323

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

Upvotes: 1

sarwar026
sarwar026

Reputation: 3821

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
    }

}

Upvotes: 2

Related Questions