Search code examples
asp.netgridviewxmldatasource

Asp.Net GridView order data bound columns before declarative ones


I have a gridview that is databound to a XmlDataSource. I also want to add a <columns> section with a buttonfield at the end of the gridview. When I add a columns section it prepends it (before xml columns). How could I order

<asp:XmlDataSource ID="xmlDataSource1" runat="server" 
    datafile="some.xml" TransformFile="some.xslt" />
<asp:GridView ID="linksGrid" runat="server" 
  DataSourceID="xmlDataSource1" 
  CssClass="adminGrid" 
  AllowPaging="True" 
  AlternatingRowStyle-BackColor="WhiteSmoke">
    <Columns>
        <asp:ButtonField runat="server" ButtonType="Button" Text="details" />
    </Columns>
</asp:GridView>

this produces a table like this: enter image description here

I want the order to be reversed: Title, Url, Button column

bones question, how could I space the columns so the modify button has no weight (fits to column) and the remaining cells to get even space?


Solution

  • The code below will surely help you.

    <asp:GridView ID="MyGridView" runat="server" ShowFooter="True">
            <Columns>
                <asp:TemplateField > 
                    <FooterTemplate >
                        <asp:Button ID="MyButton" runat="server" Text="Click Me"/>
                    </FooterTemplate>
                </asp:TemplateField>
            </Columns>    
        </asp:GridView>