why i cannot clear the rows in the datagridview control?

I was doing this test, I need to re-load the datagridview with data every 4 seconds and the data was coming from a database.

so i'v created a timer control by code and added an event handler to the tick event. Then in the tick event

void t1_Tick(object sender, EventArgs e)

    dataGridView1.DataSource = null;
    dt = Product.GetAllProductsBasicInfo();
    dataGridView1.DataSource = dt;


above code works but when I move



dataGridView1.DataSource = null;

it will throw a run time error saying the rows cannot be cleared, I want to know why it throws this error, typically Clear() clears the datagridview?



typically Clear() clears the datagridview?

Yes, unless it has a DataSource, which in your case, it does.

So try clearing the source of the data instead:


Need Your Help

Selenium and HTTPS/SSL

ssl https selenium selenium-rc

I'm running selenium-rc 1.0.3 on a Mac OS X & Windows 7 and both seem to be giving my the annoying accept cert error in firefox. In reading the docs they say I should be able to just use the *f...

Setting onbeforeunload on body element in Chrome and IE using jQuery

javascript jquery google-chrome onbeforeunload

I have a system where I want to check with the user if they're sure they want to leave the page once a dirty flag is set.