asp.net - How to reorder columns in a datagrid Dynamically? -


After

I am using autogeneratecolumns = "false" and using some template fields.

This works when I use:

  tempColumnNew = Me.DataGrid.Columns (oldColIndex) tempColumnOld = Me.DataGrid.Columns (newColIndex) Me.DataGrid .Columns.RemoveAt (oldColIndex) my  

But it does not remember the added columns on postback, so I add them to every postback.

Is there a better way to implement it?

are you using on the Page_Load event?

  If No IsPostBack then tempColumnNew = Me.DataGrid.Columns (oldColIndex) tempColumnOld = Me.DataGrid.Columns (newColIndex) Me.DataGrid.Columns.RemoveAt (oldColIndex) Me.DataGrid.Columns. RemoveAt (newColIndex) Me.DataGrid.Columns.AddAt (oldColIndex, tempColumnOld) Me.DataGrid.Columns.AddAt (newColIndex, tempColumnNew) end then  

Comments

Popular posts from this blog

paypal - How to know the URL referrer in PHP? -

oauth - Facebook OAuth2 Logout does not remove fb_ cookie -

wpf - Line breaks and indenting for the XAML of a saved FlowDocument? -