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

c# - sqlDecimal to decimal clr stored procedure Unable to cast object of type 'System.Data.SqlTypes.SqlDecimal' to type 'System.IConvertible' -

Calling GetGUIThreadInfo from Outlook VBA -

Obfuscating Python code? -