Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DataGridView not updating in c# [duplicate]

Anyone got an explanation of what's going on? Changing code 1 to code 2 fixes the problem -although theoretically there should be no difference. (Theory hits practice like a pumpkin hitting a brick wall).


Code 1:

 OutputDataGridView.DataSource = myList;

Code 2:

 OutputDataGridView.DataSource = null;
 OutputDataGridView.DataSource = myList;
like image 912
Larry Watanabe Avatar asked Dec 07 '09 07:12

Larry Watanabe


1 Answers

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

like image 116
ACP Avatar answered Sep 30 '22 15:09

ACP