protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         if (Request.QueryString["ProgramacionInformeId"] != null)
         {
             prgInf = CntInforme.GetProgramacionInforme(int.Parse(Request.QueryString["ProgramacionInformeId"]), ctx);
             CargaControles(prgInf);
         }
         else
         {
             CargaControles(null);
         }
     }
 }
    protected void RadGrid1_ItemCommand(object sender, GridCommandEventArgs e)
    {
        // we only process commands with a datasource (our image buttons)
        if (e.CommandSource == null)
        {
            return;
        }
        string typeOfControl = e.CommandSource.GetType().ToString();

        if (typeOfControl.Equals("System.Web.UI.WebControls.ImageButton"))
        {
            int         id   = 0;
            ImageButton imgb = (ImageButton)e.CommandSource;
            if (imgb.ID != "New" && imgb.ID != "Exit")
            {
                id = int.Parse(e.Item.OwnerTableView.DataKeyValues[e.Item.ItemIndex][e.Item.OwnerTableView.DataKeyNames[0]].ToString());
            }
            switch (imgb.ID)
            {
            case "Select":
                break;

            case "Edit":
                break;

            case "Delete":
                try
                {
                    ProgramacionInforme p = CntInforme.GetProgramacionInforme(id, ctx);
                    foreach (InformeProgramado ip in p.InformeProgramados)
                    {
                        ip.ProgramacionInforme = null;
                    }
                    CntLainsaSci.CTXEliminar(p, ctx);
                    CntLainsaSci.CTXGuardar(ctx);
                    RefreshGrid(true);
                }
                catch (Exception ex)
                {
                    ControlDeError(ex);
                }
                break;
            }
        }
    }