I have a datagrid with a quantity column that's updatable on all rows. Each rows is "e.Item.Edit = true;" I use ItemCommand's UpdateAll to get the updated quantity when the user edits those quantity rows. However, they have to click "refresh cart" button to get the update going to execute the ItemCommand. I would like the review button to execute an update of the Cart prior to moving to the next page. When I try to manually trigger the itemCommand w/ "UpdateAll" I get an error because I can't completely emulate the event
I have a datagrid with a quantity column that's updatable on all rows. Each rows is "e.Item.Edit = true;" I use ItemCommand's UpdateAll to get the updated quantity when the user edits those quantity rows. However, they have to click "refresh cart" button to get the update going to execute the ItemCommand. I would like the review button to execute an update of the Cart prior to moving to the next page. When I try to manually trigger the itemCommand w/ "UpdateAll" I get an error because I can't completely emulate the event
grdOrderCart_ItemCommand(object source, GridCommandEventArgs e)
{
case "UpdateAll":
//this.UpdateOrderHeaderFields();
//Update Cart
DataRow dr;
foreach (GridEditableItem editedItem in grdOrderCart.EditItems)
{
Hashtable newValues = new Hashtable();
//The GridTableView will fill the values from all editable columns in the hash
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
//skip just added items.
if (newValues["Quantity"] != null)
{
if (dt.Rows.Find(editedItem.GetDataKeyValue("ItemNo")) != null)
{
dr = dt.Rows.Find(editedItem.GetDataKeyValue("ItemNo"));
dr["Quantity"] = newValues["Quantity"];
dr.AcceptChanges();
}
}
}
}
grdOrderCart_ItemCommand(object source, GridCommandEventArgs e)
{
I have a datagrid with a quantity column that's updatable on all rows. Each rows is "e.Item.Edit = true;" I use ItemCommand's UpdateAll to get the updated quantity when the user edits those quantity rows. However, they have to click "refresh cart" button to get the update going to execute the ItemCommand. I would like the review button to execute an update of the Cart prior to moving to the next page. When I try to manually trigger the itemCommand w/ "UpdateAll" I get an error because I can't completely emulate the event
//Force Grid into EDIT mode.
CommandEventArgs eee = new CommandEventArgs("UpdateAll", "Hello");
GridCommandEventArgs ee = new GridCommandEventArgs(null, "UpdateAll", eee);
grdOrderCart_ItemCommand(grdOrderCart, ee);
grdOrderCart.Rebind();
protected void grdOrderCart_ItemCommand(object source, GridCommandEventArgs e)
{
DataTable dt = dsDSD.Tables[B2B.DSD.Tables.OrderCart];
dt.PrimaryKey =
new DataColumn[] { dt.Columns["ItemNo"] };
switch (e.CommandName)
{
case "Delete":
string itemNo = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["ItemNo"].ToString();
string desc = e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex]["Description"].ToString();
if (dt.Rows.Find(itemNo) != null)
{
dt.Rows.Find(itemNo).Delete();
lblMessages.Text +=
string.Format("<br>Deleted: {0} - {1}", itemNo, desc);
dt.AcceptChanges();
}
break;
case "UpdateAll":
//this.UpdateOrderHeaderFields();
//Update Cart
DataRow dr;
foreach (GridEditableItem editedItem in grdOrderCart.EditItems)
{
Hashtable newValues = new Hashtable();
//The GridTableView will fill the values from all editable columns in the hash
e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
//skip just added items.
if (newValues["Quantity"] != null)
{
if (dt.Rows.Find(editedItem.GetDataKeyValue("ItemNo")) != null)
{
dr = dt.Rows.Find(editedItem.GetDataKeyValue(
"ItemNo"));
dr[
"Quantity"] = newValues["Quantity"];
dr.AcceptChanges();
}
}