Q:

C#: Changing the order of columns when binding DataTable to a GridView

How is it possible to change the displayed order of columns from a DataTable?  
For example, dataTable "dt" contains two columns "a" and "b". I bind it to a GridView like this:
gridView.DataSource = dt;
gridView.DataBind();

But I'd like the GridView to display "b" first (leftmost). 
Important point: I'm using this to export to Excel and there's no actual output to screen, using:
 HtmlTextWriter htw = new HtmlTextWriter(sw);
 gridView.RenderControl(htw);

Thanks!

A:

yes you can do it in the front end. Something along these lines:
<asp:GridView runat="server" AutoGenerateColumns="false">
    <Columns>
        <asp:BoundField DataField="b" />
        <asp:BoundField DataField="a" />
    </Columns>
</asp:GridView>

EDIT:
No front end you say? That's cool - I like a challenge:
            gridView.AutoGenerateColumns = false;
        gridView.Columns.Add(new BoundField { DataField = "b" });
        gridView.Columns.Add(new BoundField { DataField = "a" });

(It's cool to assume C#3 these days isn't it?)

