开发者

Will a Winforms grid keep its datasource in memory? .Net

开发者 https://www.devze.com 2023-01-03 04:39 出处:网络
I\'ve a grid in my winforms application and i bind a huge dataset to the grid. Will the dataset be stored in the memory by the grid after calling DataBind(). How does it operate on the data binded to

I've a grid in my winforms application and i bind a huge dataset to the grid. Will the dataset be stored in the memory by the grid after calling DataBind(). How does it operate on the data binded to the grid?

Update

I wrote the following code

DataTable dt = new DataTable();
        using (SqlConnection con = new SqlConnection("Server=server;Initial Catalog=db;User ID=testv;Pwd=pass"))
        {
            con.Open();
            using (SqlCommand com = new SqlCommand("select * from tbl_Sample", con))
            {
                using (SqlDataAdapter ada = new SqlDataAdapter(com))
                {
                    ada.Fill开发者_运维问答(dt);
                    dgvMain.DataSource = dt;
                    dt.Dispose();
                }
            }
        }

After assigning the datatable as the datasource i'm able to dispose it. So does it make a copy in the memory?

Thanks

NLV


It doesn't make a copy, it makes a reference to the original datasource object.

P.S. Making a huge dataset is not a good idea anyway. If you need to display lots of rows, make some kind of paging or filters and restrict number of rows to load and display.

0

精彩评论

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