FindControl help...please

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave

    #1

    FindControl help...please

    I have a web page that I'm trying to toggle between current data and
    archived data. So far so good. To preserver the integrity of the
    archived data, I need to disable the Edit, Delete, and New links in
    the Form View. The below code is what I've been trying to use, and
    I've tried it in various events with no luck. I need some help.

    Control btn1 = this.fvCapture. FindControl("Ed itButton");
    Control btn2 = fvCapture.FindC ontrol("NewButt on");
    Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
    Button b1 = btn1 as Button;
    Button b2 = btn2 as Button;
    Button b3 = btn3 as Button;
    if (b1 != null)
    {
    b1.Enabled = false;
    }
    if (b2 != null)
    {
    b2.Enabled = false;
    }
    if (b3 != null)
    {
    b3.Enabled = false;
    }

    Thankyou

  • Liz

    #2
    Re: FindControl help...please


    "Dave" <Dave.Burkett@J acobs.comwrote in message
    news:1194562323 .590083.271330@ i38g2000prf.goo glegroups.com.. .
    >I have a web page that I'm trying to toggle between current data and
    archived data. So far so good. To preserver the integrity of the
    archived data, I need to disable the Edit, Delete, and New links in
    the Form View. The below code is what I've been trying to use, and
    I've tried it in various events with no luck. I need some help.
    Hard to figure your context ... but this worked fine for me:

    Button b = (Button)FormVie w1.FindControl( "editButton ");

    b.Enabled = false;

    I just handled a button on dropped on the FormView to look at this ... don't
    know what event you're trying to handle but not sure why it should matter ..

    >
    Control btn1 = this.fvCapture. FindControl("Ed itButton");
    Control btn2 = fvCapture.FindC ontrol("NewButt on");
    Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
    Button b1 = btn1 as Button;
    Button b2 = btn2 as Button;
    Button b3 = btn3 as Button;
    if (b1 != null)
    {
    b1.Enabled = false;
    }
    if (b2 != null)
    {
    b2.Enabled = false;
    }
    if (b3 != null)
    {
    b3.Enabled = false;
    }
    >
    Thankyou
    >

    Comment

    • Liz

      #3
      Re: FindControl help...please


      "Dave" <Dave.Burkett@J acobs.comwrote in message
      news:1194562323 .590083.271330@ i38g2000prf.goo glegroups.com.. .
      >I have a web page that I'm trying to toggle between current data and
      archived data. So far so good. To preserver the integrity of the
      archived data, I need to disable the Edit, Delete, and New links in
      the Form View. The below code is what I've been trying to use, and
      I've tried it in various events with no luck. I need some help.
      >
      Control btn1 = this.fvCapture. FindControl("Ed itButton");
      Control btn2 = fvCapture.FindC ontrol("NewButt on");
      Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
      Button b1 = btn1 as Button;
      Button b2 = btn2 as Button;
      Button b3 = btn3 as Button;
      if (b1 != null)
      {
      b1.Enabled = false;
      }
      if (b2 != null)
      {
      b2.Enabled = false;
      }
      if (b3 != null)
      {
      b3.Enabled = false;
      }
      btw, I also tried your construct:

      Control b2 = FormView1.FindC ontrol("newButt on");

      Button b22 = b2 as Button;

      b22.Enabled = false;

      and it worked too .... apparently, your FindControl call is not finding;
      must be in the wrong level of the containment hierarchy ... if you cannot
      get this going you could just try to handle the database events and cancel
      them before they occur if the program state is "archive" ... not as elegant
      of course .. but workable if you're in a bind






      Comment

      • Dave

        #4
        Re: FindControl help...please

        Liz,
        Thanks for your help and Comments. Where would you suggest that I put
        it in the containment hierarchy?

        Dave


        On Nov 9, 12:42 am, "Liz" <l...@tiredofsp am.comwrote:
        "Dave" <Dave.Burk...@J acobs.comwrote in message
        >
        news:1194562323 .590083.271330@ i38g2000prf.goo glegroups.com.. .
        >
        >
        >
        >
        >
        I have a web page that I'm trying to toggle between current data and
        archived data. So far so good. To preserver the integrity of the
        archived data, I need to disable the Edit, Delete, and New links in
        the Form View. The below code is what I've been trying to use, and
        I've tried it in various events with no luck. I need some help.
        >
        Control btn1 = this.fvCapture. FindControl("Ed itButton");
        Control btn2 = fvCapture.FindC ontrol("NewButt on");
        Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
        Button b1 = btn1 as Button;
        Button b2 = btn2 as Button;
        Button b3 = btn3 as Button;
        if (b1 != null)
        {
        b1.Enabled = false;
        }
        if (b2 != null)
        {
        b2.Enabled = false;
        }
        if (b3 != null)
        {
        b3.Enabled = false;
        }
        >
        btw, I also tried your construct:
        >
        Control b2 = FormView1.FindC ontrol("newButt on");
        >
        Button b22 = b2 as Button;
        >
        b22.Enabled = false;
        >
        and it worked too .... apparently, your FindControl call is not finding;
        must be in the wrong level of the containment hierarchy ... if you cannot
        get this going you could just try to handle the database events and cancel
        them before they occur if the program state is "archive" ... not as elegant
        of course .. but workable if you're in a bind- Hide quoted text -
        >
        - Show quoted text -

        Comment

        • Liz

          #5
          Re: FindControl help...please


          "Dave" <Dave.Burkett@J acobs.comwrote in message
          news:1194614499 .821743.303220@ t8g2000prg.goog legroups.com...
          Liz,
          Thanks for your help and Comments. Where would you suggest that I put
          it in the containment hierarchy?
          where it belongs? lol ... sorry; I'm not all that clear on this issue and
          only have a snippet of your code, and I'd like to get clear on it;
          meanwhile, have a look at these links which appear to be a good start on
          sorting it out:

          http://msdn2.microsoft.com/en-us/lib...ss(vs.80).aspx
          http://msdn2.microsoft.com/en-us/lib...0b(VS.80).aspx
          http://msdn2.microsoft.com/en-us/lib...fb(VS.80).aspx

          apparently fvCapture is not adequate as an unambiguous naming container in
          your code .. you might turn on Trace and look at the Control tree too ..

          maybe someone else has a firm grasp on this ... I think part of the problem
          is that controls which use templates can generate multiple instances of a
          child controls that have to be resolved through reference to the particular
          naming container in which they reside .. and that seems to be the case even
          where, for example, your button only exists in one of the templates and does
          not repeat (or maybe not ... because I *can* get a reference to the button
          in my FormView)

          anyway, the MSDN articles should be a start ... let us know when this is
          fully resolved !

          L



          On Nov 9, 12:42 am, "Liz" <l...@tiredofsp am.comwrote:
          >"Dave" <Dave.Burk...@J acobs.comwrote in message
          >>
          >news:119456232 3.590083.271330 @i38g2000prf.go oglegroups.com. ..
          >>
          >>
          >>
          >>
          >>
          >I have a web page that I'm trying to toggle between current data and
          archived data. So far so good. To preserver the integrity of the
          archived data, I need to disable the Edit, Delete, and New links in
          the Form View. The below code is what I've been trying to use, and
          I've tried it in various events with no luck. I need some help.
          >>
          Control btn1 = this.fvCapture. FindControl("Ed itButton");
          Control btn2 = fvCapture.FindC ontrol("NewButt on");
          Control btn3 = fvCapture.FindC ontrol("DeleteB utton");
          Button b1 = btn1 as Button;
          Button b2 = btn2 as Button;
          Button b3 = btn3 as Button;
          if (b1 != null)
          {
          b1.Enabled = false;
          }
          if (b2 != null)
          {
          b2.Enabled = false;
          }
          if (b3 != null)
          {
          b3.Enabled = false;
          }
          >>
          >btw, I also tried your construct:
          >>
          >Control b2 = FormView1.FindC ontrol("newButt on");
          >>
          >Button b22 = b2 as Button;
          >>
          >b22.Enabled = false;
          >>
          >and it worked too .... apparently, your FindControl call is not finding;
          >must be in the wrong level of the containment hierarchy ... if you cannot
          >get this going you could just try to handle the database events and
          >cancel
          >them before they occur if the program state is "archive" ... not as
          >elegant
          >of course .. but workable if you're in a bind- Hide quoted text -
          >>
          >- Show quoted text -
          >
          >

          Comment

          Working...