protected void gvPedidos_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Alterar")) { int Linha = int.Parse(e.CommandArgument.ToString()); int ID = int.TryParse(gvPedidos.Rows[Linha].Cells[0].Text, out ID) ? ID : 0; try { PedidoBll PedidoBll = new PedidoBll(); ProdutoBll ProdutoBll = new ProdutoBll(); Pedido Pedido = PedidoBll.RetornarPedido(ID); hfID.Value = Pedido.ID.ToString(); txtDocumento.Text = Pedido.Documento; txtDataEntrega.Text = string.Format("{0:dd/MM/yyyy}", Pedido.DataEntrega); var Produtos = ProdutoBll.RetornarPedidoProdutos(Pedido.ID); gvProdutos.DataSource = Produtos; gvProdutos.DataBind(); ViewState["Produtos"] = Produtos.ToDataTable(); } catch (Exception ex) { Msg.Erro(Resource.ContateAdminstrador, this); } } }