Click here to Skip to main content
15,893,381 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have edit and delete button i want it at End of row

What I have tried:

<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_RowCommand" CssClass="table table-responsive">
Posted
Updated 18-Oct-16 7:27am

Do you need the edit and delete button at the end of each row inside the gridview? if yes, Go to youur gridview properties, click on collections, then select template column and choose button field. That should add a button at the end of the row.
 
Share this answer
 
v2
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.NET
<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:
C#
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e){

        GridViewRow row = e.Row;
        // Intitialize TableCell list
        List<tablecell> columns = new List<tablecell>();
        foreach (DataControlField column in GridView1.Columns)
        {
            //Get the first Cell /Column
            TableCell cell = row.Cells[0];
            // Then Remove it after
            row.Cells.Remove(cell);
            //And Add it to the List Collections
            columns.Add(cell);
        }

        // Add cells
        row.Cells.AddRange(columns.ToArray());
}
</tablecell></tablecell>


The code above will move the autogenerated columns to the left most column in your GridView.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900