You could easily arrange the order of the
Columns
within the
GridView
if you set
AutogenerateColumns
property to
false
.
Since you were using
AutogenerateColumns
, then you could try something like this:
<asp:gridview id="GridView1" runat="server" onrowcreated="GridView1_RowCreated" cssclass="table table-responsive">
<columns>
<asp:commandfield showeditbutton="True">
</asp:commandfield></columns>
</asp:gridview>
Code Behind:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e){
GridViewRow row = e.Row;
List<tablecell> columns = new List<tablecell>();
foreach (DataControlField column in GridView1.Columns)
{
TableCell cell = row.Cells[0];
row.Cells.Remove(cell);
columns.Add(cell);
}
row.Cells.AddRange(columns.ToArray());
}
</tablecell></tablecell>
The code above will move the autogenerated columns to the left most column in your
GridView
.