Sunday, 21 October 2012

GridView Insert Select Delete Fields, Custom

I am still in the process of customising these fields, but to simply move this to the right for example, you can use:

<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AllowSorting="True" AutoGenerateColumns="False" GridLines="None"
DataKeyNames="Category_ID" DataSourceID="CategoryDataSource"
CssClass="table" onrowcreated="GridView1_RowCreated"
PagerSettings-Mode="NextPreviousFirstLast" AutoGenerateDeleteButton="True">
<Columns>
<asp:BoundField DataField="Category_ID" HeaderText="Category ID"
SortExpression="Category_ID" Visible="false" />
<asp:BoundField DataField="Category_Title" HeaderText="Category Title"
SortExpression="Category_Title" />
<asp:CheckBoxField DataField="Category_Visible" HeaderText="Make Visible?"
SortExpression="Category_Visible" />
<asp:CommandField ShowEditButton="true" />
<asp:CommandField ShowDeleteButton="true" />
<asp:CommandField ShowInsertButton="true" />
</Columns>
</asp:GridView>

I will be updated this is due course with more information.


UPDATE:

Error: Delete is disabled for this control.

This was yet another simple but hard to find solution

On your Entitydatasource add EnableDelete="true" EnableInsert="true" EnableUpdate="true"

Now you can update your records as you wish.

Shame this wasnt more obivous as I wasted such a long time on this.






No comments: