Getting Value of particular key in gridview datakeys
Posted: Fri Feb 06, 2009 12:36 pm
I'm adapting the EditSimilarProducts.ascx to use to link webpages of a custom type to a product.
The SearchResultsGrid now has three data keys, CategoryId, CatalogNodeId, CatalogNodeTypeId.
The RelatedProductGrid has 4 keys, objectId1, objecctType1, objectId2, objectType2
When I add/remove a link, the objectId1 is the parent productId and the objectType1 is 1 since it's a product.
I need to map the CatalogNodeId to the objectId2 and the CatalogNodeTypeId to the objectType2.
I'm changing the following:
to
but something is not picking up for the keys for tempId and tempType. The code keeps picking up the CategoryId and saving that to the objectId2 in the database with 0 in the objectType2 field.
Can anyone tell me how to edit the above? I can change the order of the DataKeyNames="CategoryId,CatalogNodeId,CatalogNodeTypeId" to put the CatalogNodeId first and then that gets put into the database OK, but the type doesn't get put in.
Thanks
The SearchResultsGrid now has three data keys, CategoryId, CatalogNodeId, CatalogNodeTypeId.
The RelatedProductGrid has 4 keys, objectId1, objecctType1, objectId2, objectType2
When I add/remove a link, the objectId1 is the parent productId and the objectType1 is 1 since it's a product.
I need to map the CatalogNodeId to the objectId2 and the CatalogNodeTypeId to the objectType2.
I'm changing the following:
Code: Select all
protected void RelatedProductGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int relatedProductId = (int)e.Keys[0];
SetLink(relatedProductId, false);
//CHECK THE SEARCH RESULTS GRID TO SEE IF THIS ITEMS APPEARS
int tempIndex = 0;
foreach (DataKey key in SearchResultsGrid.DataKeys)
{
int tempId = (int)key.Value;
if (relatedProductId == tempId)
Code: Select all
protected void RelatedObjectGrid_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int relatedObjectId = (int)e.Keys[2];
int relatedType = (int)e.Keys[3];
SetLink(relatedObjectId,relatedType, false);
//CHECK THE SEARCH RESULTS GRID TO SEE IF THIS ITEMS APPEARS
int tempIndex = 0;
int tempId = (int)SearchResultsGrid.DataKeys[1].Value;
int tempType = (byte)SearchResultsGrid.DataKeys[2].Value;
Can anyone tell me how to edit the above? I can change the order of the DataKeyNames="CategoryId,CatalogNodeId,CatalogNodeTypeId" to put the CatalogNodeId first and then that gets put into the database OK, but the type doesn't get put in.
Thanks