Hello all,
I've built some pages that are similar to the /admin/ManageCategories.aspx page where the data list is viewed in a GridView and when clicking the "edit" button it populates in a DetailsView for editing. (this works fine).
Now, I'm trying to change it so that it simply (at least I thought it would be) instead of dropping the data into a DetailsView for editing, it stays in the Grid for editing, but I seem to be having a problem. After updating, the changes don't take effect.
I tried accomplishing this in TBH sample project for testing and I'm having the same problem. Here's the code for the GridView and ObjectDataSource.
Code:
<asp:ObjectDataSource ID="objCategories" runat="server"
TypeName="TBH.TheBeerHouse.BLL.Articles.Category"
SelectMethod="GetCategories"
InsertMethod="InsertCategory"
UpdateMethod="UpdateCategory"
DeleteMethod="DeleteCategory">
<DeleteParameters>
<asp:Parameter Name="id" Type="Int32" />
</DeleteParameters>
<UpdateParameters>
<asp:Parameter Name="id" Type="Int32" />
<asp:Parameter Name="title" Type="String" />
<asp:Parameter Name="importance" Type="Int32" />
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="imageUrl" Type="String" />
</UpdateParameters>
<InsertParameters>
<asp:Parameter Name="title" Type="String" />
<asp:Parameter Name="importance" Type="Int32" />
<asp:Parameter Name="description" Type="String" />
<asp:Parameter Name="imageUrl" Type="String" />
</InsertParameters>
</asp:ObjectDataSource>
<asp:GridView ID="gvwCategories" runat="server"
AutoGenerateColumns="False"
DataKeyNames="ID"
DataSourceID="objCategories">
<Columns>
<asp:CommandField ShowDeleteButton="True" ShowEditButton="True" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Importance" HeaderText="Importance" SortExpression="Importance" />
<asp:BoundField DataField="Description" HeaderText="Description" SortExpression="Description" />
<asp:BoundField DataField="ImageUrl" HeaderText="ImageUrl" SortExpression="ImageUrl" />
<asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID" />
<asp:BoundField DataField="AddedDate" HeaderText="AddedDate" ReadOnly="True" SortExpression="AddedDate" />
<asp:BoundField DataField="AddedBy" HeaderText="AddedBy" ReadOnly="True" SortExpression="AddedBy" />
</Columns>
</asp:GridView>
I made sure to add the DataKeyNames="ID" to the GridView. Yet all I'm getting after selecting the "Edit" from the GridView (ShowEditButton="true") and editing any of the fields is NO CHANGE. And just to recap, this works in the TBH GridView/DetailsView ManageCategories.aspx page.
If anyone can shed some light on what I'm missing I'd be really appreciative.
Thank you,
Ronnie