protected void GridViewAdmin_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "EditRow") { int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; GridViewAdmin.EditIndex = rowIndex; GridViewDataBind(); } else if (e.CommandName == "DeleteRow") { ItemDataProcess.DeletePublishersByID(Convert.ToInt32(e.CommandArgument)); GridViewDataBind(); } else if (e.CommandName == "CancelUpdate") { GridViewAdmin.EditIndex = -1; GridViewDataBind(); } else if (e.CommandName == "UpdateRow") { int rowIndex = ((GridViewRow)((LinkButton)e.CommandSource).NamingContainer).RowIndex; Publisher publisher = new Publisher(); publisher.PublisherId = Convert.ToInt32(e.CommandArgument); publisher.Name = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxPublisherName")).Text; publisher.Address = ((TextBox)GridViewAdmin.Rows[rowIndex].FindControl("TextBoxPublisherAddress")).Text; GridViewAdmin.EditIndex = -1; ItemDataProcess.UpdatePublishers(publisher); GridViewDataBind(); } else if (e.CommandName == "InsertRow") { Publisher publisher = new Publisher(); publisher.Name = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtName")).Text; publisher.Address = ((TextBox)GridViewAdmin.FooterRow.FindControl("txtAddress")).Text; ItemDataProcess.InsertPublishers(publisher); GridViewDataBind(); } }