/// <summary> /// Salva o conteúdo do grid no ViewState /// </summary> public bool SalvaConteudoGrid(out string msgErro) { string mensagemErro = ""; foreach (GridViewRow linha in _grvContatoNomeTel.Rows) { string id = _grvContatoNomeTel.DataKeys[linha.RowIndex].Value.ToString(); int index = RetornaIndice(id); if (VerificaLinhaPreenchida(linha.RowIndex)) { _VS_contatos.Rows[index]["fmc_nome"] = ((TextBox)linha.FindControl("txtContatoNome")).Text; _VS_contatos.Rows[index]["fmc_telefone"] = ((TextBox)linha.FindControl("txtContatoTelefone")).Text; if (VS_Mostra_Tipo_Responsaveis) { WebControls_Combos_UCComboTipoResponsavelAluno UCComboTipoResponsavelAluno1 = ((WebControls_Combos_UCComboTipoResponsavelAluno)linha.FindControl("UCComboTipoResponsavelAluno1")); _VS_contatos.Rows[index]["tra_id"] = UCComboTipoResponsavelAluno1.Valor; } } else { if (index != -1) { _VS_contatos.Rows[index].Delete(); } } } msgErro = mensagemErro; return(true); }
protected void _grvContatoNomeTelefone_RowDataBound(object sender, GridViewRowEventArgs e) { if (e.Row.RowType == DataControlRowType.DataRow) { ImageButton btnExcluir = (ImageButton)e.Row.FindControl("btnExcluir"); if (btnExcluir != null) { btnExcluir.CommandArgument = e.Row.RowIndex.ToString(); btnExcluir.Visible = __SessionWEB.__UsuarioWEB.GrupoPermissao.grp_excluir; } ImageButton btnSubir = (ImageButton)e.Row.FindControl("btnSubir"); if (btnSubir != null) { btnSubir.ImageUrl = __SessionWEB._AreaAtual._DiretorioImagens + "cima.png"; btnSubir.Visible = __SessionWEB.__UsuarioWEB.GrupoPermissao.grp_alterar && e.Row.RowIndex > 0; } ImageButton btnDescer = (ImageButton)e.Row.FindControl("btnDescer"); if (btnDescer != null) { btnDescer.ImageUrl = __SessionWEB._AreaAtual._DiretorioImagens + "baixo.png"; btnDescer.Visible = __SessionWEB.__UsuarioWEB.GrupoPermissao.grp_alterar && e.Row.RowIndex < _VS_contatos.AsEnumerable().Select(r => r.RowState != DataRowState.Deleted).Count() - 1; } //Se o usercontrol de tipo de responsaveis estiver visivel, o grid de contatos é percorrido e o combo de tipo //de responsaveis é preenchido e tem o valor setado para a linha selecionada. if (VS_Mostra_Tipo_Responsaveis) { string id = _grvContatoNomeTel.DataKeys[e.Row.RowIndex].Value.ToString(); int index = RetornaIndice(id); WebControls_Combos_UCComboTipoResponsavelAluno UCComboTipoResponsavelAluno1 = ((WebControls_Combos_UCComboTipoResponsavelAluno)e.Row.FindControl("UCComboTipoResponsavelAluno1")); UCComboTipoResponsavelAluno1.Combo.DataSource = _VS_Tipo_Responsaveis; UCComboTipoResponsavelAluno1.DataBind(); int tra_id = -1; if (!string.IsNullOrEmpty(_VS_contatos.Rows[index]["tra_id"].ToString())) { tra_id = Convert.ToInt32(_VS_contatos.Rows[index]["tra_id"].ToString()); } UCComboTipoResponsavelAluno1.Valor = tra_id; } } }