开发者

DataGridView not updating in c# [duplicate]

开发者 https://www.devze.com 2022-12-13 20:53 出处:网络
This question already has answers here: Refresh DataGridView when updating data source (8 answers) Closed 3 years ago.
This question already has answers here: Refresh DataGridView when updating data source (8 answers) Closed 3 years ago.

Anyone got an explanation of what's going on? Changing code 1 to code 2 fixes the problem -although theoretically there should be no differ开发者_运维问答ence. (Theory hits practice like a pumpkin hitting a brick wall).


Code 1:

 OutputDataGridView.DataSource = myList;

Code 2:

 OutputDataGridView.DataSource = null;
 OutputDataGridView.DataSource = myList;


protected void btnWhateverClick(object sender, EventArgs e)
{
    myGridView.DataSourceID = String.Empty;
    myGridView.DataSource = new int[0];
    myGridView.DataBind();
}

and you're done.

For Ref DataSource in gridview

0

精彩评论

暂无评论...
验证码 换一张
取 消