开发者

Data populated wrongly in DataGridView

I have a DataGridView that is populated using a list. During Runtime, the user can filter the data by entering data in a textbox. I am able to do the filtering part.

But the problem i am facing is when i change the datasource to the new datasource in the Textbox1_TextChanged event, the datagridview is populating the data with rows equa开发者_JS百科l to the number of rows in my new datasource but each row is replica of the first row.

When I check the DataSource of the datagridview it has the data of the new DataSource.

So when I check the row selected in the datagridview_doubleclick event, the DataBoundItem gives me the exact object that it should give according the to new datasource.

What might have gone wrong??


Maybe I am wrong, but do you need to clear the DataGridView when binding to a new datasource.... my binding skills are lacking....

Try clearing the DataGridView, before changing the datasource like :

DataGridView.Rows.Clear();
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜