I am assigning a datasource to the datagridview and it works fine but only for the first time. When I assign the datasource a second time it doesn't show the data. My code is:
gridProjectEdit.DataSource = null;
gridProjectEdit.Columns.Clear();
gridProjectEdit.Rows.Clear();
gridProjectEdit.Refresh();
if(dt!=null)
dt.Clear();
dt=methodCaller.GetProjectData(); //get the data
gridProjectEdit.DataSource = dt; //copying datatable
copyOfProjectDataTable = dt.Copy(); //this datatable used to check sno
I also rename the column headers ahead like this, if it matters:
//renaming column header
gridProjectEdit.Columns[0].HeaderText = "S.NO.";
gridProjectEdit.Columns[1].HeaderText = "PROJECTNAME";
When I debugged this code the second time it showed the datatable having 6 rows but I don't know why it doesn't show the data, it shows only column headers.