none
动态查找控件的问题---FindControl,控件树中已经包括了要查找的控件 RRS feed

  • 问题

  • 跟踪结果,控件树如下:
    __Page ASP.worksheet_zxsb_aspx 8213 0 0
        ctl23 System.Web.UI.LiteralControl 174 0 0
        ctl00 System.Web.UI.HtmlControls.HtmlHead 134 0 0
            ctl01 System.Web.UI.HtmlControls.HtmlTitle 51 0 0
            ctl02 System.Web.UI.HtmlControls.HtmlLink 70 0 0
        ctl24 System.Web.UI.LiteralControl 14 0 0
        form1 System.Web.UI.HtmlControls.HtmlForm 7871 0 0
            ctl25 System.Web.UI.LiteralControl 27 0 0
            ctl03 System.Web.UI.WebControls.Table 323 0 0
                ctl26 System.Web.UI.WebControls.TableRow 149 0 0
                    ctl27 System.Web.UI.WebControls.TableCell 114 0 0
            ctl04 System.Web.UI.WebControls.Table 6382 0 0
                ctl28 System.Web.UI.WebControls.TableRow 356 0 0
                    ctl29 System.Web.UI.WebControls.TableCell 140 0 0
                    ctl30 System.Web.UI.WebControls.TableCell 180 0 0
                        ctl05 System.Web.UI.Control 83 0 0
                            QYMC1 System.Web.UI.WebControls.TextBox 83 0 0
                ctl31 System.Web.UI.WebControls.TableRow 672 0 0
                    ctl32 System.Web.UI.WebControls.TableCell 140 0 0
                    ctl33 System.Web.UI.WebControls.TableCell 180 0 0
                        ctl06 System.Web.UI.Control 83 0 0
                            JYFW2 System.Web.UI.WebControls.TextBox 83 0 0
                    ctl34 System.Web.UI.WebControls.TableCell 138 0 0
                    ctl35 System.Web.UI.WebControls.TableCell 179 0 0
                        ctl07 System.Web.UI.Control 82 0 0
                            JYFS3 System.Web.UI.WebControls.TextBox 82 0 0
                ctl36 System.Web.UI.WebControls.TableRow 355 0 0
                    ctl37 System.Web.UI.WebControls.TableCell 140 0 0
                    ctl38 System.Web.UI.WebControls.TableCell 180 0 0
                        ctl08 System.Web.UI.Control 83 0 0
                            ZCDZ4 System.Web.UI.WebControls.TextBox 83 0 0
                ctl39 System.Web.UI.WebControls.TableRow 682 0 0
                    ctl40 System.Web.UI.WebControls.TableCell 143 0 0
                    ctl41 System.Web.UI.WebControls.TableCell 182 0 0
                        ctl09 System.Web.UI.Control 85 0 0
                            YXKZH5 System.Web.UI.WebControls.TextBox 85 0 0
                    ctl42 System.Web.UI.WebControls.TableCell 138 0 0
                    ctl43 System.Web.UI.WebControls.TableCell 184 0 0
                        ctl10 System.Web.UI.Control 87 0 0
                            GSPZSH6 System.Web.UI.WebControls.TextBox 87 0 0
                ctl44 System.Web.UI.WebControls.TableRow 454 0 0
                    ctl45 System.Web.UI.WebControls.TableCell 140 0 0
                    ctl46 System.Web.UI.WebControls.TableCell 279 0 0
                        ctl11 System.Web.UI.Control 91 0 0
                            SZQY7_0 System.Web.UI.WebControls.CheckBox 91 0 0
                        ctl12 System.Web.UI.Control 91 0 0
                            SZQY7_1 System.Web.UI.WebControls.CheckBox 91 0 0
                ctl47 System.Web.UI.WebControls.TableRow 634 0 0
                    ctl48 System.Web.UI.WebControls.TableCell 140 0 0
                    ctl49 System.Web.UI.WebControls.TableCell 138 0 0
                    ctl50 System.Web.UI.WebControls.TableCell 174 0 0
                    ctl51 System.Web.UI.WebControls.TableCell 147 0 0
                ctl52 System.Web.UI.WebControls.TableRow 1117 0 0
                    ctl53 System.Web.UI.WebControls.TableCell 140 0 0
                    ctl54 System.Web.UI.WebControls.TableCell 138 0 0
                    ctl55 System.Web.UI.WebControls.TableCell 132 0 0
                    ctl56 System.Web.UI.WebControls.TableCell 135 0 0
                    ctl57 System.Web.UI.WebControls.TableCell 138 0 0
                    ctl58 System.Web.UI.WebControls.TableCell 132 0 0
                    ctl59 System.Web.UI.WebControls.TableCell 135 0 0
                    ctl60 System.Web.UI.WebControls.TableCell 132 0 0
                ctl61 System.Web.UI.WebControls.TableRow 1938 0 0
                    ctl62 System.Web.UI.WebControls.TableCell 192 0 0
                        ctl13 System.Web.UI.Control 82 0 0
                            ZGZS9 System.Web.UI.WebControls.TextBox 82 0 0
                    ctl63 System.Web.UI.WebControls.TableCell 212 0 0
                        ctl14 System.Web.UI.Control 104 0 0
                            CSZLGLYSYHRYZS10 System.Web.UI.WebControls.TextBox 104 0 0
                    ctl64 System.Web.UI.WebControls.TableCell 192 0 0
                        ctl15 System.Web.UI.Control 84 0 0
                            ZYYS12 System.Web.UI.WebControls.TextBox 84 0 0
                    ctl65 System.Web.UI.WebControls.TableCell 192 0 0
                        ctl16 System.Web.UI.Control 84 0 0
                            ZRYS13 System.Web.UI.WebControls.TextBox 84 0 0
                    ctl66 System.Web.UI.WebControls.TableCell 188 0 0
                        ctl17 System.Web.UI.Control 80 0 0
                            YS14 System.Web.UI.WebControls.TextBox 80 0 0
                    ctl67 System.Web.UI.WebControls.TableCell 190 0 0
                        ctl18 System.Web.UI.Control 82 0 0
                            ZYS15 System.Web.UI.WebControls.TextBox 82 0 0
                    ctl68 System.Web.UI.WebControls.TableCell 192 0 0
                        ctl19 System.Web.UI.Control 84 0 0
                            CYYS16 System.Web.UI.WebControls.TextBox 84 0 0
                    ctl69 System.Web.UI.WebControls.TableCell 188 0 0
                        ctl20 System.Web.UI.Control 80 0 0
                            YS17 System.Web.UI.WebControls.TextBox 80 0 0
                    ctl70 System.Web.UI.WebControls.TableCell 190 0 0
                        ctl21 System.Web.UI.Control 82 0 0
                            ZYS18 System.Web.UI.WebControls.TextBox 82 0 0
                    ctl71 System.Web.UI.WebControls.TableCell 188 0 0
                        ctl22 System.Web.UI.Control 80 0 0
                            QT19 System.Web.UI.WebControls.TextBox 80 0 0
            hdPid System.Web.UI.HtmlControls.HtmlInputHidden 78 0 0
            ctl72 System.Web.UI.LiteralControl 10 0 0
            hdDeptid System.Web.UI.HtmlControls.HtmlInputHidden 71 0 0
            ctl73 System.Web.UI.LiteralControl 10 0 0
            hdReporder System.Web.UI.HtmlControls.HtmlInputHidden 67 0 0
            ctl74 System.Web.UI.LiteralControl 132 0 0
            btnSave System.Web.UI.WebControls.Button 86 0 0
            ctl75 System.Web.UI.LiteralControl 88 0 0
        ctl76 System.Web.UI.LiteralControl 20 0 0


     
    但使用如Page.FindControl("QYMC1"),返回的结果值为null
    我看过相关的这方面的解答,我感觉我所找的这个控件是在naming container中,但为什么找不到呢?
    请哪位专家帮助解决一下,不胜感激.
    2009年10月12日 8:08

答案

  • 你好!

    你查看一下源代码,看看是否有这个控件ID或者控件ID是否为QYMC1

    知识改变命运,奋斗成就人生!
    2009年10月12日 8:14
    版主

全部回复

  • 你好!

    你查看一下源代码,看看是否有这个控件ID或者控件ID是否为QYMC1

    知识改变命运,奋斗成就人生!
    2009年10月12日 8:14
    版主
  • 谢谢版主,问题跟前面的添加事件一样,都是写到了IsPostBack中了.
    现在问题已经解决---关键就是动态生成的东西不能写到IsPostBack中.
    谢谢

    2009年10月12日 8:30