Accessing multiple controls inside listview

2 posts, 0 answers
  1. Josh
    Josh avatar
    7 posts
    Member since:
    May 2012

    Posted 01 Aug 2012 Link to this post

    I have set of controls inside of a list view in which I want to be disabled until a certain checkbox is checked.
    My current code looks like this:
    protected void chckRSMCA_CheckedChanged(object sender, EventArgs e)
    {
                CheckBox checkboxRS = (CheckBox)sender;
                RadTextBox Id = (RadTextBox)rlvListView.FindControl("txtRSFarmIdMCA");
                RadTextBox Address = (RadTextBox)rlvListView.FindControl("txtRSSvrAddressMCA");
     
                if (checkboxRS.Checked)
                {
                    Id.Enabled = true;
                    Address.Enabled = true;
                }
                else
                {
                    Id.Enabled = false;
                    Address.Enabled = false;
                }
    }

    However, with this code I get null reference exception when it tries to set the Enabled setting.
  2. Josh
    Josh avatar
    7 posts
    Member since:
    May 2012

    Posted 01 Aug 2012 Link to this post

    Figured it out.
    This code works however, there was a simple typo.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top