1
votes

I have a table in MySQL with more than 7000 rows and about 20 fields. I want my user be able to select a single row.

I use common code to fill my DataGridView instance named as dataGridView1 with this table. The code is:

MySqlCommand cmd = new MySqlCommand(sql, con);
MySqlDataAdapter adapter = new MySqlDataAdapter(cmd);
DataTable dt = new DataTable();
adapter.Fill(dt);
dataGridView1.DataSource = dt.DefaultView;

Although this works, but it always cost more than 10 seconds to display the filled dataGridView1. I remember in web GridView control, it pages it's content to get much better performance.

My question is: can I also page DataGridView control to get better performance?

1
I have edited your title. Please see, "Should questions include “tags” in their titles?", where the consensus is "no, they should not".John Saunders

1 Answers

0
votes

can I also page DataGridView control to get better performance

Yes, you can. And you should do the paging on server side. You can take a quick look Datagrid paging to see what you need to do.

Note: The code in the example is not the best way to do. It is just an example of how it can be done.