Reputation:
This is the GridView :
<asp:GridView ID="grdProduct" runat="server" AllowPaging="True" AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="sdsProducts" OnSelectedIndexChanged="grdProduct_SelectedIndexChanged" Width="1000px" BackColor="White" BorderColor="#CCCCCC" BorderStyle="Solid" BorderWidth="1px" CellPadding="4" Font-Names="Arial" Font-Underline="False" ForeColor="Black">
<AlternatingRowStyle VerticalAlign="Middle" />
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID"/>
<asp:BoundField DataField="Name" HeaderText="Nom" SortExpression="Name" />
<asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/dataG/cancel.png" DeleteImageUrl="~/Images/dataG/delete.png" EditImageUrl="~/Images/dataG/edit.png" InsertImageUrl="~/Images/dataG/insert.png" ShowEditButton="True" UpdateImageUrl="~/Images/dataG/update.png" />
<asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/dataG/cancel.png" DeleteImageUrl="~/Images/dataG/delete.png" EditImageUrl="~/Images/dataG/edit.png" InsertImageUrl="~/Images/dataG/insert.png" ShowDeleteButton="True" UpdateImageUrl="~/Images/dataG/update.png" />
</Columns>
<FooterStyle BackColor="#CCCC99" ForeColor="Black" />
<HeaderStyle BackColor="#333333" Font-Bold="True" Font-Underline="False" ForeColor="White" />
<PagerStyle BackColor="White" ForeColor="Black" HorizontalAlign="Center" VerticalAlign="Middle" />
<RowStyle HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#CC3333" Font-Bold="True" ForeColor="White" />
<SortedAscendingCellStyle BackColor="#F7F7F7" />
<SortedAscendingHeaderStyle BackColor="#4B4B4B" />
<SortedDescendingCellStyle BackColor="#E5E5E5" />
<SortedDescendingHeaderStyle BackColor="#242121" />
It gives me this result :
--------------------------------
|ID | Name | | |
--------------------------------
| 1 | x | Edit | Delete|
| 2 | y | Edit | Delete|
| 3 | z | Edit | Delete|
--------------------------------
But i want it to be like this :
--------------------------------
|ID | Name | Action |
--------------------------------
| 1 | x | Edit Delete|
| 2 | y | Edit Delete|
| 3 | z | Edit Delete|
--------------------------------
Thank you :D
Upvotes: 0
Views: 55
Reputation: 613
You can use one TemplateField with a HeaderText = "Action" to do this, instead of the two CommandFields. In the TemplateField, you can add the buttons as regular elements.
Upvotes: 0