why doesn't datagridview refresh?

前端 未结 9 2224
-上瘾入骨i
-上瘾入骨i 2021-01-02 18:19

here is what happens after i press a button:

    dataGridView1.DataSource = ConnectandReadList(some_query);
    dataGridView1.Refresh();

pl

相关标签:
9条回答
  • 2021-01-02 18:51

    Did you try calling EndEdit() before Refresh() ?

    0 讨论(0)
  • 2021-01-02 18:51

    Are you initializing the datasource the first time in an if(!Page.IsPostback)

    It may be reseting the datasource on each postback.

    0 讨论(0)
  • 2021-01-02 18:53

    You could do as @cycl suggested, you could also use a BindingSource which I believe is the recommended method by microsoft.

    BindingSource bs = new BindingSource(); 
    bs.DataSource = ConnectandReadList(some_query);
    dataGridView1.DataSource = bs;
    dataGridView1.Refresh;
    
    0 讨论(0)
提交回复
热议问题