Referencing child controls on a formview

Discussion in 'ASP .Net' started by Neil, Feb 7, 2006.

  1. Neil

    Neil Guest

    I want to be able to set the enabled status of certain controls on the
    edititem template of a formview control based on whether a check box is
    checked or not (or the value coming from the database as stored by the
    sqldatasource) .

    I've tried code such as:

    CheckBox cb =
    (CheckBox)FormView1.Row.FindControl("SysDefMethod");
    Button ub = (Button)FormView1.Row.FindControl("UpdateButton");
    if (cb.Checked == true)
    {
    ub.Enabled = false;
    }

    in various events (formview databound & databinding, sqldatasource
    selected) but always get an "Object reference not set to an instance of
    an object." exception when the "if (cb.Checked == true)" line is
    executed.

    The item to be displayed in the formview is chosen from a gridview. I
    have no problem getting the data displayed or updated, its just that I
    now want to restrict the fields that are available to the user based on
    the value of SysDefMethod (it's a bit field in the database).


    Thanks in advance
    Neil, Feb 7, 2006
    #1
    1. Advertising

  2. Neil

    Neil Guest

    Does no-one have a solution for this.

    I can't see anything mentioned in books or on MSDN as to how I can do
    this.

    Neil
    Neil, Feb 8, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Neil
    Replies:
    0
    Views:
    553
  2. Replies:
    1
    Views:
    440
  3. Ned Balzer
    Replies:
    4
    Views:
    2,433
    Ned Balzer
    Aug 3, 2006
  4. Replies:
    0
    Views:
    195
  5. Replies:
    2
    Views:
    306
Loading...

Share This Page