.FindControl not seeing control

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?cm9kY2hhcg==?=

    .FindControl not seeing control

    hey all,
    i've added a dropdownlist object into tableCell td in my code
    further down the code
    i inspect the td.Controls
    and i can see the the dropdownlist bright as day.
    however, when i try to do
    td.FindControl( 'id')
    it returns null?

    any ideas off the top why this may be?

    thanks,
    rodchar
  • Ignacio Machin ( .NET/ C# MVP )

    #2
    Re: .FindControl not seeing control

    On Mar 26, 5:09 pm, rodchar <rodc...@discus sions.microsoft .comwrote:
    hey all,
    i've added a dropdownlist object into tableCell td in my code
    further down the code
    i inspect the td.Controls
    and i can see the the dropdownlist bright as day.
    however, when i try to do
    td.FindControl( 'id')
    it returns null?
    >
    any ideas off the top why this may be?
    >
    thanks,
    rodchar
    Take a look at the page's code and see if the control was renamed, it
    might happens that the control is renamed if it's inside a grid (or
    any list control for that matter). If so you need to search using the
    ClientId

    Comment

    • =?Utf-8?B?cm9kY2hhcg==?=

      #3
      Re: .FindControl not seeing control

      if i look at the page's code you're right it did get renamed because it's
      coming from a user control, however take a look at the time of debugging,
      just to show i'm not crazy here's the debug Immediate results:
      ?td.Controls[0]
      {System.Web.UI. WebControls.Dro pDownList}
      [System.Web.UI.W ebControls.Drop DownList]:
      {System.Web.UI. WebControls.Dro pDownList}
      AppRelativeTemp lateSourceDirec tory: "~/"
      BindingContaine r: null
      ClientID: "drpJD_Job_Cate gory"
      Controls: {System.Web.UI. EmptyControlCol lection}
      EnableTheming: true
      EnableViewState : true
      ID: "drpJD_Job_Cate gory"
      NamingContainer : null
      Page: null
      Parent: {System.Web.UI. WebControls.Tab leCell}
      Site: null
      SkinID: ""
      TemplateControl : null
      TemplateSourceD irectory: "/hrrc"
      UniqueID: "drpJD_Job_Cate gory"
      Visible: true
      ?td.FindControl ("drpJD_Job_Cat egory")
      null

      "Ignacio Machin ( .NET/ C# MVP )" wrote:
      On Mar 26, 5:09 pm, rodchar <rodc...@discus sions.microsoft .comwrote:
      hey all,
      i've added a dropdownlist object into tableCell td in my code
      further down the code
      i inspect the td.Controls
      and i can see the the dropdownlist bright as day.
      however, when i try to do
      td.FindControl( 'id')
      it returns null?

      any ideas off the top why this may be?

      thanks,
      rodchar
      >
      Take a look at the page's code and see if the control was renamed, it
      might happens that the control is renamed if it's inside a grid (or
      any list control for that matter). If so you need to search using the
      ClientId
      >

      Comment

      • Ignacio Machin ( .NET/ C# MVP )

        #4
        Re: .FindControl not seeing control

        On Mar 26, 6:01 pm, rodchar <rodc...@discus sions.microsoft .comwrote:
        if i look at the page's code you're right it did get renamed because it's
        coming from a user control, however take a look at the time of debugging,
        just to show i'm not crazy here's the debug Immediate results:
        ?td.Controls[0]
        {System.Web.UI. WebControls.Dro pDownList}
            [System.Web.UI.W ebControls.Drop DownList]:
        {System.Web.UI. WebControls.Dro pDownList}
            AppRelativeTemp lateSourceDirec tory: "~/"
            BindingContaine r: null
            ClientID: "drpJD_Job_Cate gory"
            Controls: {System.Web.UI. EmptyControlCol lection}
            EnableTheming: true
            EnableViewState : true
            ID: "drpJD_Job_Cate gory"
            NamingContainer : null
            Page: null
            Parent: {System.Web.UI. WebControls.Tab leCell}
            Site: null
            SkinID: ""
            TemplateControl : null
            TemplateSourceD irectory: "/hrrc"
            UniqueID: "drpJD_Job_Cate gory"
            Visible: true
        ?td.FindControl ("drpJD_Job_Cat egory")
        null
        >
        "Ignacio Machin ( .NET/ C# MVP )" wrote:
        >
        >
        >
        On Mar 26, 5:09 pm, rodchar <rodc...@discus sions.microsoft .comwrote:
        hey all,
        i've added a dropdownlist object into tableCell td in my code
        further down the code
        i inspect the td.Controls
        and i can see the the dropdownlist bright as day.
        however, when i try to do
        td.FindControl( 'id')
        it returns null?
        >
        any ideas off the top why this may be?
        >
        thanks,
        rodchar
        >
        Take a look at the page's code and see if the control was renamed, it
        might happens that the control is renamed if it's inside a grid (or
        any list control for that matter). If so you need to search using the
        ClientId- Hide quoted text -
        >
        - Show quoted text -
        Hi,

        I fail to see what you want me to see.Sorry.

        You know now the problem, the control is being renamed, either you
        save the name of the control (by using ControlClientId ) or you have to
        search it by type, you could transverse the controls, looking for the
        one you need.

        Usually I keep the name of the controls I need using a
        CommandArgument s (I prefer to using OnCommand over OnClick)

        Comment

        • =?Utf-8?B?cm9kY2hhcg==?=

          #5
          Re: .FindControl not seeing control

          well, as i showed in the debugging output above i'm doing a

          ?td.Controls[0]

          and it finds the object i'm looking for, however, if i say

          ?td.FindControl ("drpJD_Job_Cat egory")

          it is null.

          how can that be?


          "Ignacio Machin ( .NET/ C# MVP )" wrote:
          On Mar 26, 6:01 pm, rodchar <rodc...@discus sions.microsoft .comwrote:
          if i look at the page's code you're right it did get renamed because it's
          coming from a user control, however take a look at the time of debugging,
          just to show i'm not crazy here's the debug Immediate results:
          ?td.Controls[0]
          {System.Web.UI. WebControls.Dro pDownList}
          [System.Web.UI.W ebControls.Drop DownList]:
          {System.Web.UI. WebControls.Dro pDownList}
          AppRelativeTemp lateSourceDirec tory: "~/"
          BindingContaine r: null
          ClientID: "drpJD_Job_Cate gory"
          Controls: {System.Web.UI. EmptyControlCol lection}
          EnableTheming: true
          EnableViewState : true
          ID: "drpJD_Job_Cate gory"
          NamingContainer : null
          Page: null
          Parent: {System.Web.UI. WebControls.Tab leCell}
          Site: null
          SkinID: ""
          TemplateControl : null
          TemplateSourceD irectory: "/hrrc"
          UniqueID: "drpJD_Job_Cate gory"
          Visible: true
          ?td.FindControl ("drpJD_Job_Cat egory")
          null

          "Ignacio Machin ( .NET/ C# MVP )" wrote:


          On Mar 26, 5:09 pm, rodchar <rodc...@discus sions.microsoft .comwrote:
          hey all,
          i've added a dropdownlist object into tableCell td in my code
          further down the code
          i inspect the td.Controls
          and i can see the the dropdownlist bright as day.
          however, when i try to do
          td.FindControl( 'id')
          it returns null?
          any ideas off the top why this may be?
          thanks,
          rodchar
          Take a look at the page's code and see if the control was renamed, it
          might happens that the control is renamed if it's inside a grid (or
          any list control for that matter). If so you need to search using the
          ClientId- Hide quoted text -
          - Show quoted text -
          >
          Hi,
          >
          I fail to see what you want me to see.Sorry.
          >
          You know now the problem, the control is being renamed, either you
          save the name of the control (by using ControlClientId ) or you have to
          search it by type, you could transverse the controls, looking for the
          one you need.
          >
          Usually I keep the name of the controls I need using a
          CommandArgument s (I prefer to using OnCommand over OnClick)
          >

          Comment

          • =?Utf-8?B?cm9kY2hhcg==?=

            #6
            Re: .FindControl not seeing control

            requesting 2nd look at post above, or could i post a new post pointing to
            this one for a possible 2nd look at this issue.

            "rodchar" wrote:
            well, as i showed in the debugging output above i'm doing a
            >
            ?td.Controls[0]
            >
            and it finds the object i'm looking for, however, if i say
            >
            ?td.FindControl ("drpJD_Job_Cat egory")
            >
            it is null.
            >
            how can that be?
            >
            >
            "Ignacio Machin ( .NET/ C# MVP )" wrote:
            >
            On Mar 26, 6:01 pm, rodchar <rodc...@discus sions.microsoft .comwrote:
            if i look at the page's code you're right it did get renamed because it's
            coming from a user control, however take a look at the time of debugging,
            just to show i'm not crazy here's the debug Immediate results:
            ?td.Controls[0]
            {System.Web.UI. WebControls.Dro pDownList}
            [System.Web.UI.W ebControls.Drop DownList]:
            {System.Web.UI. WebControls.Dro pDownList}
            AppRelativeTemp lateSourceDirec tory: "~/"
            BindingContaine r: null
            ClientID: "drpJD_Job_Cate gory"
            Controls: {System.Web.UI. EmptyControlCol lection}
            EnableTheming: true
            EnableViewState : true
            ID: "drpJD_Job_Cate gory"
            NamingContainer : null
            Page: null
            Parent: {System.Web.UI. WebControls.Tab leCell}
            Site: null
            SkinID: ""
            TemplateControl : null
            TemplateSourceD irectory: "/hrrc"
            UniqueID: "drpJD_Job_Cate gory"
            Visible: true
            ?td.FindControl ("drpJD_Job_Cat egory")
            null
            >
            "Ignacio Machin ( .NET/ C# MVP )" wrote:
            >
            >
            >
            On Mar 26, 5:09 pm, rodchar <rodc...@discus sions.microsoft .comwrote:
            hey all,
            i've added a dropdownlist object into tableCell td in my code
            further down the code
            i inspect the td.Controls
            and i can see the the dropdownlist bright as day.
            however, when i try to do
            td.FindControl( 'id')
            it returns null?
            >
            any ideas off the top why this may be?
            >
            thanks,
            rodchar
            >
            Take a look at the page's code and see if the control was renamed, it
            might happens that the control is renamed if it's inside a grid (or
            any list control for that matter). If so you need to search using the
            ClientId- Hide quoted text -
            >
            - Show quoted text -
            Hi,

            I fail to see what you want me to see.Sorry.

            You know now the problem, the control is being renamed, either you
            save the name of the control (by using ControlClientId ) or you have to
            search it by type, you could transverse the controls, looking for the
            one you need.

            Usually I keep the name of the controls I need using a
            CommandArgument s (I prefer to using OnCommand over OnClick)

            Comment

            Working...