ArrayList array = new ArrayList(); 
         array.Add("dd"); 
         array.Add("sss"); 
         dGridMyList.DataSource = null; 
         dGridMyList.Refresh();          this.dGridMyList.DataSource = array; 
         this.dGridMyList.Refresh(); 
这样绑定的效果是ArrayList 里每个元素的长度,即为“2”,“3”,为什么啊? 
请高手指点 

解决方案 »

  1.   

    ArrayList array = new ArrayList(); 
             array.Add("dd"); 
             array.Add("sss"); 
             dGridMyList.DataSource = null; 
             //dGridMyList.Refresh();          this.dGridMyList.DataSource = array; 
             this.dGridMyList.DataBind();这种方法貌似可以。。
    顺便问一下,Refresh()是干什么用的,看不太懂。
      

  2.   

    改一下即可。DataGrid 之类的控件并不支持基元类型的直接绑定。public class MyString
    {
    public MyString(string s)
    {
    this.s = s;
    } private string s;
    public string S
    {
    get { return s; }
    set { s = value; }
    }
    }ArrayList list = new ArrayList();
    list.Add(new MyString("aa"));
    list.Add(new MyString("bbbb"));
    this.dataGridView1.DataSource = list;
      

  3.   

    补充:WebForm 中可以直接显示。