Inventory Admin Modification
Posted: Wed Sep 30, 2009 12:10 pm
I am attempting to add a SKU column to the inventory admin and then trying to get it to be sortable. So far I have made these modifications to the Admin/Catalog/Inventory.aspx page...
That pulls the proper SKUs and displays them on the page next to their corresponding Product Names. However, it does not sort on the SKU column. Pops up the error "Exception has been thrown by target of invocation." I'm sure it's because I have not added the proper coding to do the sort by Sku, but how would I do that? Is it something that is possible to do in the source code or would it require modifications to the app itself?
Any ideas or suggestions are appreciated.
Thanks,
Wil
Code: Select all
// Get the corresponding Sku info
protected string GetSku(object dataItem)
{
ProductInventoryDetail detail = (ProductInventoryDetail)dataItem;
if (detail.ProductVariantId.Equals(0)) {
Product product = ProductDataSource.Load(detail.ProductId);
return product.Sku;
} else {
ProductVariant variant = ProductVariantDataSource.Load(detail.ProductVariantId);
return variant.Sku;
}
}
Code: Select all
// Display the Sku info
<asp:TemplateField HeaderText="Sku" SortExpression="Sku">
<ItemTemplate>
<asp:HyperLink ID="SKULink" runat="server" Text='<%# GetSku(Container.DataItem) %>' NavigateUrl='<%#Eval("ProductId", "../Products/EditProduct.aspx?ProductId={0}")%>'></asp:HyperLink>
</ItemTemplate>
<HeaderStyle HorizontalAlign="Left" />
</asp:TemplateField>
Any ideas or suggestions are appreciated.
Thanks,
Wil