Exemplo n.º 1
0
    private void cambiarContenido()
    {
        try
        {
            WSHabitat.WS_HabitadClient client2 = new WSHabitat.WS_HabitadClient();
            string    fileJSON = client2.consultaHabitad();
            DataTable dt       = (DataTable)JsonConvert.DeserializeObject(fileJSON, typeof(DataTable));

            foreach (GridViewRow grid_row in GridView_Animales.Rows)
            {
                foreach (DataRow data_row in dt.Rows)
                {
                    if (grid_row.Cells[10].Text.Equals(Convert.ToString(data_row["id"])))
                    {
                        grid_row.Cells[10].Text = Convert.ToString(data_row["descripcion"]);
                    }
                }

                if (grid_row.Cells[11].Text.Equals("PER5"))
                {
                    grid_row.Cells[11].Text = "Permanente";
                }
                else
                {
                    grid_row.Cells[11].Text = "Prestado";
                }
            }
        } catch (Exception ex) {
            Response.Write("<script language=javascript> alert('" + ex.Message + "'); </script>");
        }
    }
 protected void Page_Load(object sender, EventArgs e)
 {
     try {
         client = new WSHabitat.WS_HabitadClient();
         string    fileJSON = client.consultaHabitad();
         DataTable dt       = (DataTable)JsonConvert.DeserializeObject(fileJSON, typeof(DataTable));
         GridView_Habitats.DataSource = dt;
         if (!IsPostBack)
         {
             GridView_Habitats.DataBind();
         }
     } catch (Exception ex) {
         Response.Write("<script language=javascript> alert('" + ex.Message + "'); </script>");
     }
 }
    private void llenarList()
    {
        try {
            WSHabitat.WS_HabitadClient client2 = new WSHabitat.WS_HabitadClient();
            string    fileJSON = client2.consultaHabitad();
            DataTable dt       = (DataTable)JsonConvert.DeserializeObject(fileJSON, typeof(DataTable));

            foreach (DataRow row in dt.Rows)
            {
                string descripcion = Convert.ToString(row["descripcion"]);
                ddlHabitat.Items.Add(descripcion);
                string id = Convert.ToString(row["id"]);
                ddlID.Items.Add(id);
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script language=javascript> alert('" + ex.Message + "'); </script>");
        }
    }