比如我一个TextBox在FormView中绑定了一个列,那么我如何在runtime的时候取到它所绑定的列的列名呢?
我知道在Designtime时可以通过在Designer里写IDesignerHost.GetDesigner()函数取到ControlDesigner,然后在通过ControlDesigner.DataBindings这个集合里取到我要的Expression,但是在runtime却不存在Designer,不知道有没有在runtime可以解决此对应问题的办法?这个问题困扰了我很久,可不可以帮帮我,万分感谢!!!

解决方案 »

  1.   

    TextBox是你自己写的自定义控件?还是只要在 FormView的DataBinding事件中得到当前列名?
      

  2.   

    是自定义的要怎么写?
    如果不是的话FormView的DataBinding事件中又如何得到当前列名
      

  3.   

    我用
    void t1_DataBinding(object sender, EventArgs e)
        {
            TextBox t = (TextBox)sender;
            Response.Write(((IDataBindingsAccessor)t).DataBindings.Count);
            
     
            
            
        }
    得到的却是0
      

  4.   

    http://www.cnblogs.com/califord/category/76812.html
      

  5.   

    to:幕白兄
    IDataBindingsAccessor也是设计时才有用的