public void DetaGrid_bookcate_ItemCommand(object sender, DataGridCommandEventArgs e)
{
// this event fires prior to all of the other commands
// use it to provide a more graceful transition out of edit mode
DetailCheckIsEditing(e.CommandName);
}
public void DetailCheckIsEditing(string commandName)
{
if (DetaGrid_bookcate.EditItemIndex != -1)
{
// we are currently editing a row
if (commandName != "Cancel" && commandName != "Update")
{
// user's edit changes (if any) will not be committed
// Message.InnerHtml = "在選擇另一條目前,請先保存或取消對當前條目的修改!";
isEditing = true;
}
}
}
2.method:
protected void DataGrid_OrderInfo_ItemCommand(object source, DataGridCommandEventArgs e)
{
if (e.CommandName == "Memo")
{
//獲取控件中的選定項的索引
this.DataGrid_OrderInfo.SelectedIndex = e.Item.ItemIndex;
if(DataGrid_OrderInfo.SelectedIndex == -1)
{
this.OrdersDetail.Visible = true;
Memo = this.txtMemo.Text.Trim();
IsDel = this.chkIsDel.Checked.ToString();
Datetimed = Convert.ToDateTime(this.txtDateTimed.Text.Trim());
CustomerId = Convert.ToInt32(this.txtCustomerId.Text.Trim());
ShipDate = Convert.ToDateTime(this.txtshipDated.Text.Trim());
Hasview = this.chkHasView.Checked.ToString();
Hascheck = this.chkHasCheck.Checked.ToString();
Hassend = this.chkHasSend.Checked.ToString();
HasReceive = this.chkHasReceive.Checked.ToString();
adminPub.spDataGrid_OrderInfo_ItemCommand(Memo, IsDel, Datetimed, CustomerId, ShipDate, Hasview, Hascheck, Hassend, HasReceive);
int CartId = Convert.ToInt32(Request.Params["CartId"].ToString());
int ProductId = Convert.ToInt32(Request.Params["ProductId"].ToString());
//展示購物車中的商品
BindDatagrid_ShoppingCart(CartId, ProductId);
}
else
{
Response.Write("<script language=javascript>alert('請註冊爲正式會員纔行')</script>");
}
}
}
如果沒有在代碼中沒有DataGrid_CannelCommand() and DataGrid_UpdateCommand() 時就採用第二種方法。