简体   繁体   中英

How to sort Gridview items

I have a dynamically created gridview in c# asp.net that I need sorted when you load the page. How can this be done? I am using gridview1.DataBind() to bind.

try this

DataTable table = GetTable();
table.DefaultView.Sort = "SortCondition";

//
// Display all records in the view.
//
DataView view = table.DefaultView;

Now Bind the grid

 GridView1.DataSource=view;
 GirdView1.DataBind();

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