简体   繁体   中英

How i can sort data in Datagridview by Column name

I have LINQ query:

var product_view = from productallinfo in QProductAllInfo select productallinfo;

Then i load data to table

MainCatalog_Table.DataSource = product_view.Distinct();

And next i want sort data by column name for example "ProductName"

Why don't you sort it before you bind it to the DataSource, something like this:

var product_view = from productallinfo in QProductAllInfo 
                   orderby productallinfo.ProductName
                   select productallinfo;

And then you bind it to your data source....

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM