// lrojas:25/08/2016(1) ; 30/08/2016(2) protected void GVSolicitud_RowCommand(object sender, GridViewCommandEventArgs e) { try { string tipo = Convert.ToString(e.CommandName); int rowIndex = Convert.ToInt32(e.CommandArgument); string IdSolicitud = LblIdSolicitud.Text; //Session.Add("IdSolicitud", GVSolicitud.Rows[rowIndex].Cells[0].Text); DB_VT_Solicitud DB_Sol = new DB_VT_Solicitud(); VT_SolicitudDestino Obj_SD = new VT_SolicitudDestino(); switch (tipo) { case "Delete": string NroReg = Convert.ToString(GVSolicitud.DataKeys[rowIndex].Values[0]); DateTime fechaDelete = DateTime.Now; DB_Sol.DB_DELETE_SOLICITUD_DESTINO(IdSolicitud, NroReg, fechaDelete); DB_VT_Solicitud lista = new DB_VT_Solicitud(); VT_SolicitudDestino ObjSD = new VT_SolicitudDestino(); GVSolicitud.DataSource = lista.DB_Desplegar_SOLICITUD_DESTINOS(LblIdSolicitud.Text); GVSolicitud.DataBind(); int numero = lista.DB_Numero_Filas_SOLICITUD(LblIdSolicitud.Text); // se modifico query con 'cont>0' int Aux_Cont = 1; foreach (GridViewRow dgi in GVSolicitud.Rows) { int Cont = Convert.ToInt32(GVSolicitud.DataKeys[rowIndex].Values[0]); if (Cont > 0) { DropDownList ddlZona = (DropDownList)dgi.Cells[3].Controls[1]; DropDownList ddlDestino = (DropDownList)dgi.Cells[4].Controls[1]; TextBox txLugar = (TextBox)dgi.Cells[5].Controls[1]; TextBox tx1Objetivo = (TextBox)dgi.Cells[6].Controls[1]; TextBox tx2 = (TextBox)dgi.Cells[7].Controls[1]; DropDownList ddlHora = (DropDownList)dgi.Cells[8].Controls[1]; DropDownList ddlMin = (DropDownList)dgi.Cells[9].Controls[1]; DropDownList ddlVia_Transporte = (DropDownList)dgi.Cells[10].Controls[1]; DropDownList ddlTipo_Transporte = (DropDownList)dgi.Cells[11].Controls[1]; TextBox txNombre_Transporte = (TextBox)dgi.Cells[12].Controls[1]; TextBox txIdentificador_Trasporte = (TextBox)dgi.Cells[13].Controls[1]; ObjSD.Id_Solicitud = LblIdSolicitud.Text; ObjSD.Cont = Convert.ToInt32(GVSolicitud.DataKeys[rowIndex].Values[0]); ObjSD.Tramo = GVSolicitud.Rows[dgi.RowIndex].Cells[2].Text; ObjSD.Zona = ddlZona.SelectedValue; ObjSD.Destino = ddlDestino.SelectedValue; ObjSD.Lugar = txLugar.Text; ObjSD.Objetivo = tx1Objetivo.Text; ObjSD.Fecha_Salida = Convert.ToDateTime(tx2.Text + " " + ddlHora.SelectedValue + ":" + ddlMin.SelectedValue); ObjSD.Via_Transporte = ddlVia_Transporte.SelectedValue; ObjSD.Tipo_Transporte = ddlTipo_Transporte.SelectedValue; ObjSD.Nombre_Transporte = txNombre_Transporte.Text; ObjSD.Identificador_Trasporte = txIdentificador_Trasporte.Text; lista.DB_Modificar_SOLICITUD_DESTINO_CONT(ObjSD, Aux_Cont); if (Aux_Cont != numero) { Aux_Cont++; } } } break; } GVSolicitud.DataSource = DB_Sol.DB_Desplegar_SOLICITUD_DESTINOS(LblIdSolicitud.Text); GVSolicitud.DataBind(); } catch (Exception ex) { string script = @"<script type='text/javascript'>alert('{0}');</script>"; script = string.Format(script, ex.Message); ScriptManager.RegisterStartupScript(this, typeof(Page), "alerta", script, false); } }