Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8730805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:06:02+00:00 2026-06-13T09:06:02+00:00

i like to know how i have to use radio button CheckedChanged property when

  • 0

i like to know how i have to use radio button CheckedChanged property when the radio button there is in gridview and this gridview itself is inside of 1 user control and user control is inside of detail view control.

before i have learned how i have to find radio button control in another control. but after finding i do not know how to make CheckedChanged property for that?

protected void btnShowAddTransmittaltoCon_Click(object sender, EventArgs e)
{
    Transmittallistfortest transmittalList = (Transmittallistfortest)DetailsView1.FindControl("Transmittallistfortest1");
    GridView g3 = transmittalList.FindControl("GridViewTtransmittals") as GridView;
    foreach (GridViewRow di in g3.Rows)

    {

        RadioButton rad = (RadioButton)di.FindControl("RadioButton1");
        //Giving Error:Object reference not set to an instance of an object.
        if (rad != null && rad.Checked)
        {
            var w = di.RowIndex;

            Label1.Text = di.Cells[1].Text;
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T09:06:02+00:00Added an answer on June 13, 2026 at 9:06 am

    Replace this

    RadioButton rad = (RadioButton)di.FindControl("RadioButton1");
    

    with this:

    RadioButton rad = di.FindControl("RadioButton1") as RadioButton;
    

    You won’t get an exception but it may return NULL – in which case it’ll be caught in the ifstatement: rad != null.

    The whole point of using the as keyword is this:

    as => won’t throw an exception – it just reports null.


    By the way: You should retrieve the RadioButton this way:

    if(di.RowType == DataControlRowType.DataRow)
    {
        RadioButton rad = di.FindControl("RadioButton1") as RadioButton;
    }
    

    To define the CheckedChange event, do this:

    //rad.Checked = true;
    
    rad.CheckedChanged += new EventHandler(MyCheckedChangeEventHandler);
    

    Then define the handler:

    protected void MyCheckedChangeEventHandler)(object sender, EventArgs e)
    {
        RadioButton rb = (RadioButton)sender;
    
        if (rb.Checked)
        {
            // Your logic here...
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to know what solution I can use in order to have
I have the following html and like to know how to use xpath to
I will like to know: I have a scenario. If a user adds a
I would like to know if there is a way in Android to have
I have this group of radio buttons in which each of individual button has
I know xcode don't have radio Button so I try to add a custom
I know well that there are ways of customizing elements like GridView and ListView
i have made a template that look like this : <ControlTemplate x:Key=onoffValue TargetType={x:Type Control}>
I'd like to know which fields have been updated after an update_attributes statement. I'm
I have 4 files and would like to know elements which are non overlapping

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.