简体   繁体   中英

Change order of columns in gridview

I am using gridView. I have some auto generated columns and some generated by me. Now the column which I have generated is displayed first and then the auto generated columns. I want to display auto generated columns first and then my generated columns.

IMP Note :- I can't use this (for example): -

<asp:BoundField HeaderText="My First Column" DataField="myField1" />

because some of my Datafield columns are dynamic.

I think you add likes

 YourGridView.Columns.Add(yourNewColumn);

You can add grid column using index ,

 YourGridView.Columns.Insert(1, yourNewColumn);

In this code , the 1 makes it go into the second column (zero-based indexing ) !

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