My gridview is having a template field bound from the aspx designer. I'm binding a data table to it. Now my template field, which is having few action buttons, is coming as the first column. Is there any way to arrange the datatable columns before the template field?
Code from Designer for the GridView:
<asp:GridView ID="JobListGrid" runat="server" AutoGenerateColumns="false" >
<Columns>
<asp:TemplateField HeaderText="Actions">
<ItemTemplate>
<div>
<asp:ImageButton ID="View" CssClass="imgbutton" ToolTip="View Pdf" runat="server"
CommandArgument='<%# DataBinder.Eval(Container, "RowIndex") %>' ImageUrl="~/Content/pdf.PNG" CommandName="View" Width="36" Height="36" OnClientClick='<%# Eval("JobID", "OpenInNewWindow(\"{0}\").ToString()") %>' />
</div>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
CS Code:
JobListGrid.DataSource = dataTableObj;
JobListGrid.DataBind();
The above code shows the grid view headers like :
TemplateField | Col1 | Col2 | Col3
I need the Templatefield to come last. The col1, col, col3 are getting from the datatable.