Thursday, 5 April 2018

Shift TemplateField in gridview autogeneratecolumns in last column of the row asp.net

//////////////////////HTML

<asp:GridView runat="server" ID="GV_PersonalAttributes" AutoGenerateColumns="true"
    OnRowDataBound="GV_PersonalAttributes_RowCreated">
     <Columns>
      <asp:TemplateField HeaderText="Attributes">
       <ItemTemplate>
         <asp:LinkButton runat="server" ID="lbtn_EditObjective" Text="Edit"></asp:LinkButton>
         </ItemTemplate>
        </asp:TemplateField>
       </Columns>
    </asp:GridView>


/////////////CS


protected void GV_PersonalAttributes_RowCreated(object sender, GridViewRowEventArgs e)
    {
        TableCell cell = e.Row.Cells[0];
        e.Row.Cells.RemoveAt(0);
        e.Row.Cells.Add(cell);
    }

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...