Telerik Forums
Community Forums Forum
0 answers
1.1K+ views
such good afternoon, I was trying to update the record in the telerik: RadGrid
  I am using SqlDataSource1

alone and unable to perform query, insert, and elimar,
not allow me to perform the update of the record that I'm putting badly, or if there is a better way to perform these operations without using SqlDataSource1

another query, as I can pass values ​​from the aspx form ie values ​​of a combobox or textbox and assign an example:
assign them to the values ​​to insert or remove than the ones in the grid

  <InsertParameters>
                                    <asp:Parameter Name="usuario" />
                                    <asp:Parameter Name="f_actual" />
                                    <asp:Parameter Name="id_cliente" />
                                    <asp:Parameter Name="nomContactoCliente" />
                                    DefaultValue="agondola" <asp:Parameter Name="id_empleado" />
                                    <asp:Parameter Name="id_estado" />
                                    <asp:Parameter Name="f_tarea" />
                                    <asp:Parameter Name="descripcionTarea" />
                                    <asp:Parameter Name="cantidadHoraTarea" />
                                    DefaultValue="1" <asp:Parameter Name="id_proyecto" />
                                </ InsertParameters>


/////////////////////////////////////////////////////////////////////////////////////////////
code aspx in c#


<%@ Page Title="" Language="C#" MasterPageFile="~/ReporteHoras.Master" AutoEventWireup="true" CodeBehind="reporteHoras.aspx.cs"
Inherits="Reporte_Horas.Mantenimiento.reporteHoras" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>


<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">

    <style type="text/css">
        .GridViewStyle
        {}
        </style>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
   
   

    <telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
    </telerik:RadScriptManager>

     


     <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            <!--
            function RowDblClick(sender, eventArgs) {
              sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }

            function gridCreated(sender, args) {
//                if (sender.get_editIndexes && sender.get_editIndexes().length > 0) {
//                    document.getElementById("OutPut").innerHTML = sender.get_editIndexes().join();
//                }
//                else {
//                    document.getElementById("OutPut").innerHTML = "";
//                }
            }
            -->
        </script>
    </telerik:RadCodeBlock>

 
   

   <fieldset class="containersintitulo">

                        <fieldset style="width: 865px">
                                 <legend class="titulocontainerinterno">Consulta de Horas</legend>
                                        
                                 <table style="width: 855px">
                                     <tr>
                                         <td>
                                             <asp:Label ID="lblConsultor" runat="server" Text="Consultor"></asp:Label>
                                         </td>
                                         <td>
                                             <telerik:RadComboBox ID="ddlConsultor" Runat="server" Enabled="False"
                                                 Width="258px">
                                             </telerik:RadComboBox>
                                         </td>
                                         <td>
                                             &nbsp;</td>
                                         <td>
                                             <asp:Label ID="lblProyecto" runat="server" Text="Proyecto"></asp:Label>
                                         </td>
                                         <td>
                                             <telerik:RadComboBox ID="dllProyecto" Runat="server" Height="23px"
                                                 Width="165px">
                                             </telerik:RadComboBox>
                                         </td>
                                     </tr>
                                     <tr>
                                         <td>
                                             <asp:Label ID="lblCliente" runat="server" Text="Cliente"></asp:Label>
                                         </td>
                                         <td>
                                             <telerik:RadComboBox ID="ddlCLiente" Runat="server" AutoPostBack="True"
                                                 Width="258px" onselectedindexchanged="ddlCLiente_SelectedIndexChanged">
                                             </telerik:RadComboBox>
                                         </td>
                                         <td>
                                             &nbsp;</td>
                                         <td>
                                             <asp:Label ID="lblFechaInicio" runat="server" Text="Fecha Inicio"></asp:Label>
                                         </td>
                                         <td>
                                             <telerik:RadDatePicker ID="dpFechaInicio" Runat="server" AutoPostBack="True"
                                                 onselecteddatechanged="dpFechaInicio_SelectedDateChanged" Culture="es-PA"
                                                 Skin="Windows7">
                                                      <Calendar UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False"
                                                          ViewSelectorText="x" Skin="Windows7"></Calendar>

                                                     <DateInput DisplayDateFormat="MM/dd/yyyy" DateFormat="MM/dd/yyyy" EnableSingleInputRendering="True" LabelWidth="64px"
                                                             AutoPostBack="True"></DateInput>

                                                  <DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
                                             </telerik:RadDatePicker>
                                         </td>
                                     </tr>
                                     <tr>
                                         <td>
                                             <asp:Label ID="lblContactoCliente" runat="server" Text="Contacto del Cliente"></asp:Label>
                                         </td>
                                         <td>
                                             <asp:TextBox ID="txtContactoCliente" runat="server" Width="255px"></asp:TextBox>
                                         </td>
                                         <td>
                                             &nbsp;</td>
                                         <td>
                                             <asp:Label ID="lblFechaFin" runat="server" Text="Fecha Fin"></asp:Label>
                                         </td>
                                         <td>
                                             <telerik:RadDatePicker ID="dpFechaFin" Runat="server" Skin="Windows7"
                                                 Enabled="False">
                                                 <Calendar Skin="Windows7" UseColumnHeadersAsSelectors="False"
                                                     UseRowHeadersAsSelectors="False" ViewSelectorText="x">
                                                 </Calendar>
                                                 <DateInput DateFormat="MM/dd/yyyy" DisplayDateFormat="MM/dd/yyyy"
                                                     EnableSingleInputRendering="True" LabelWidth="64px">
                                                 </DateInput>
                                                 <DatePopupButton HoverImageUrl="" ImageUrl="" />
                                             </telerik:RadDatePicker>
                                         </td>
                                     </tr>
                                     <tr>
                                         <td>
                                             &nbsp;</td>
                                         <td>
                                             &nbsp;</td>
                                         <td>
                                             &nbsp;</td>
                                         <td>
                                             &nbsp;</td>
                                         <td>
                                             &nbsp;</td>
                                     </tr>
                                 </table>

                                 <%-- campo cantidad de horas--%>

                                <hr style="color: #3366FF;" />                              
                                

                           <asp:Label ID="lblMensajes" runat="server" ForeColor="Red"></asp:Label>

                                   
                                 <br />

                                   
                        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                             <AjaxSettings>
                                   <telerik:AjaxSetting AjaxControlID="RadGrid1">
                                        <UpdatedControls>
                                              <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                                              <telerik:AjaxUpdatedControl ControlID="RadWindowManager1" />
                                        </UpdatedControls>
                                   </telerik:AjaxSetting>

                             </AjaxSettings>
                        </telerik:RadAjaxManager>


                        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanelReporte" runat="server" />


                                 <%--Contiene los totales de horas registradas--%>      
                          
                           <telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True"
        AutoGenerateColumns="False" OnUpdateCommand="RadGrid1_UpdateCommand" OnItemUpdated ="RadGrid1_ItemUpdated"
        OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted"
                                     OnDataBound="RadGrid1_DataBound" Skin="Windows7" CellSpacing="0"
                                     onneeddatasource="RadGrid1_NeedDataSource" DataSourceID="SqlDataSource1" >
        <PagerStyle Mode="NextPrevAndNumeric" />
        <MasterTableView Width="100%" CommandItemDisplay="TopAndBottom"
                                   DataKeyNames="id_reporte, f_tarea, id_estado, descripcionTarea, cantidadHoraTarea"
                                   HorizontalAlign="NotSet" AutoGenerateColumns="False"
                                   DataSourceID="SqlDataSource1">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>

<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
            <Columns>
                <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                    <ItemStyle CssClass="MyImageButton" />
                </telerik:GridEditCommandColumn>

                <telerik:GridBoundColumn DataField="id_reporte" HeaderText="ID Reporte" SortExpression="id_reporte"
                    UniqueName="id_reporte" ColumnEditorID="GridTextBoxColumnEditor1">
                </telerik:GridBoundColumn>

                  <telerik:GridDateTimeColumn DataField="f_tarea"
                    FilterControlAltText="Filter f_tarea column" HeaderText="Fecha"
                    SortExpression="f_tarea" UniqueName="f_tarea">
                </telerik:GridDateTimeColumn>

                  <telerik:GridDropDownColumn DataField="id_estado" DataSourceID="SqlDataSource2"
                    HeaderText="Estado de Tarea" ListTextField="descripcion" ListValueField="id_estado"
                    UniqueName="id_estado" ColumnEditorID="GridDropDownColumnEditor1">
                </telerik:GridDropDownColumn>

                  <telerik:GridBoundColumn DataField="descripcionTarea"
                    HeaderText="Descripcion de Tareas" SortExpression="descripcionTarea"
                    UniqueName="descripcionTarea" ColumnEditorID="GridTextBoxColumnEditor2"
                    FilterControlAltText="Filter descripcionTarea column">
                </telerik:GridBoundColumn>

                <telerik:GridNumericColumn DataField="cantidadHoraTarea" HeaderText="Cantidad de Horas" SortExpression="cantidadHoraTarea"
                    UniqueName="cantidadHoraTarea" ColumnEditorID="GridNumericColumnEditor1" >
                </telerik:GridNumericColumn>


                <telerik:GridButtonColumn ConfirmText="Delete this product?" ConfirmDialogType="RadWindow"
                    ConfirmTitle="Delete" ButtonType="ImageButton" CommandName="Delete" Text="Delete"
                    UniqueName="DeleteColumn">
                    <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                </telerik:GridButtonColumn>

            </Columns>

            <EditFormSettings ColumnNumber="2" CaptionDataField="id_reporte" CaptionFormatString="Edit properties of Product {0}"
                InsertCaption="New Product">
                <FormTableItemStyle Wrap="False"></FormTableItemStyle>

<FormTableStyle CellPadding="2" CellSpacing="0" BackColor="White" Height="110px"></FormTableStyle>

<FormMainTableStyle CellPadding="3" CellSpacing="0" BackColor="White" Width="100%"></FormMainTableStyle>

                <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="3" BackColor="White"
                    Width="100%" />
                <FormTableStyle CellSpacing="0" CellPadding="2" Height="110px" BackColor="White" />
                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                <EditColumn ButtonType="ImageButton" InsertText="Insert Order" UpdateText="Update record"
                    UniqueName="EditCommandColumn1" CancelText="Cancel edit">
                </EditColumn>
                <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
            </EditFormSettings>
        </MasterTableView>

        <ClientSettings>
<Selecting CellSelectionMode="None"></Selecting>

            <ClientEvents OnRowDblClick="RowDblClick" OnGridCreated="gridCreated" />

<ClientEvents OnGridCreated="gridCreated" OnRowDblClick="RowDblClick"></ClientEvents>
        </ClientSettings>

<FilterMenu EnableImageSprites="False"></FilterMenu>
    </telerik:RadGrid>


  <%--  fin del grid--%>


                               

                                   <br />

                                 <%--Contiene los totales de horas registradas--%>
                                   <telerik:GridDateTimeColumnEditor ID="GridDateTimeColumnEditor1"  runat="server"  />

                                 <%--Contiene los totales de horas registradas--%>
                                 <telerik:GridDropDownListColumnEditor ID="GridDropDownColumnEditor1" runat="server"  DropDownStyle-Width="110px" />

                                 <%--Contiene los totales de horas registradas--%>
                                  <telerik:GridNumericColumnEditor ID="GridNumericColumnEditor1" runat="server"  NumericTextBox-MaxLength="2" NumericTextBox-MaxValue ="24"
                                      NumericTextBox-MinValue ="1" NumericTextBox-Width="40px" />

                                 <%--Contiene la descripcion de la tarea--%>
                                   <telerik:GridTextBoxColumnEditor ID="GridTextBoxColumnEditor1" runat="server"  TextBoxMaxLength="100" TextBoxStyle-Width="250px" />
                                 
                                

                                   <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Windows7">
                                   </telerik:RadWindowManager>


                             <br />


                           <asp:SqlDataSource ID="SqlDataSource1" runat="server"
                                     ConnectionString="<%$ ConnectionStrings:DBReporteHora %>" DeleteCommand="    DELETE FROM [ReportesHoras]
    WHERE  [ReportesHoras].id_reporte = @ID_REPORTE" InsertCommand="INSERT INTO [DBReporteHoras].[dbo].[ReportesHoras]
           ([usuario]
           ,[f_actual]
           ,[id_cliente]
           ,[nomContactoCliente]
           ,[id_empleado]
           ,[id_estado]
           ,[f_tarea]
           ,[descripcionTarea]
           ,[cantidadHoraTarea]
           ,[id_proyecto])

     VALUES    
            (
            @usuario,
            @f_actual,
            @id_cliente,
            @nomContactoCliente,
            @id_empleado,
            @id_estado,
            CONVERT(NVARCHAR(10),@f_tarea,101),
            @descripcionTarea,
            @cantidadHoraTarea,
            @id_proyecto)    "


                                     SelectCommand="SELECT r.id_reporte, r.nomContactoCliente, CONVERT (NVARCHAR(10), r.f_tarea, 103) AS f_tarea, r.descripcionTarea,
                                     r.id_estado, e.descripcion AS descripcion_estado, r.cantidadHoraTarea, r.id_empleado, r.id_cliente, r.id_proyecto FROM
                                     ReportesHoras AS r
                                     INNER JOIN Estados AS e ON r.id_estado = e.id_estado
                                     WHERE (r.id_empleado = @id_empleado)
                                      AND (r.id_proyecto = @id_cliente) AND (r.id_proyecto = @id_proyecto)
                                      AND (r.f_tarea BETWEEN @ID_F_INICIO AND @ID_F_FIN)
                                      ORDER BY r.id_reporte"
                                     
                                     
       UpdateCommand="    UPDATE  [ReportesHoras]
        SET
            
            [ReportesHoras].id_estado  = @id_estado,    
            [ReportesHoras].descripcionTarea  = @descripcionTarea,            
            [ReportesHoras].cantidadHoraTarea = @cantidadHoraTarea
        WHERE
            [ReportesHoras].ID_REPORTE = @id_reporte    "
                                     ProviderName="<%$ ConnectionStrings:DBReporteHora.ProviderName %>">
                             
                               <DeleteParameters>
                                   <asp:Parameter Name="id_reporte" />
                               </DeleteParameters>

                               <InsertParameters>
                                   <asp:Parameter  DefaultValue="agondola" Name="usuario" />
                                   <asp:Parameter  DefaultValue="datetime" Name="f_actual" />
                                   <asp:Parameter  DefaultValue="1" Name="id_cliente" />
                                   <asp:Parameter DefaultValue="1" Name="nomContactoCliente" />
                                   <asp:Parameter DefaultValue="agondola" Name="id_empleado" />
                                   <asp:Parameter Name="id_estado" />
                                   <asp:Parameter Name="f_tarea" />
                                   <asp:Parameter Name="descripcionTarea" />
                                   <asp:Parameter Name="cantidadHoraTarea" />
                                   <asp:Parameter DefaultValue="1"  Name="id_proyecto" />
                               </InsertParameters>

                               <SelectParameters>
                                   <asp:Parameter  DefaultValue="agondola" Name="id_empleado" />
                                   <asp:Parameter  DefaultValue="1" Name="id_cliente" />
                                   <asp:Parameter  DefaultValue="1" Name="id_proyecto" />
                                   <asp:Parameter  DefaultValue="2012-06-11" Name="ID_F_INICIO" />
                                   <asp:Parameter  DefaultValue="2012-06-11" Name="ID_F_FIN" />
                               </SelectParameters>

                               <UpdateParameters>
                                   <asp:Parameter Name="id_reporte" />
                                   <asp:Parameter Name="id_estado" />
                                   <asp:Parameter Name="descripcionTarea" />
                                   <asp:Parameter Name="cantidadHoraTarea" />
                               </UpdateParameters>

                           
                               </asp:SqlDataSource>



   <asp:SqlDataSource ID="SqlDataSource2" runat="server"
     ConnectionString="<%$ ConnectionStrings:DBReporteHora %>"
          SelectCommand="sp_pp_Select_Estados_Tareas" SelectCommandType="StoredProcedure"
                                     ProviderName="<%$ ConnectionStrings:DBReporteHora.ProviderName %>">
    </asp:SqlDataSource>

                                 <br />


                              <hr style="color: #3366FF; width: 845px;" />



                              <%--Contiene los totales de horas registradas--%>
                              <table>
                               <tr>
                                   <td>
                                       &nbsp;
                                       <asp:Label ID="lblHorasTrabajadas" runat="server"
                                           Text="Total de horas trabajadas:"></asp:Label>
                                   </td>
                                   <td>
                                       &nbsp;
                                       <asp:TextBox ID="txtHorastrabajadas" runat="server" Enabled="False"
                                           Width="40px"></asp:TextBox>
                                   </td>
                               </tr>
                           </table>
                      
                                        
                       </fieldset>

    </fieldset>

 
 
</asp:Content>

////////////////////////////////////////////////////////////////////////////////////////////


///////////////////////////////////////////////////////
code aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using Telerik.Web.UI.Calendar;

using System.Data.Common;
using System.IO;
using System.Data;
using System.Data.SqlClient;
using Reporte_Horas.Clases;

using System.Configuration;
using System.Collections;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Drawing;




namespace Reporte_Horas.Mantenimiento
{
    public partial class reporteHoras : System.Web.UI.Page
    {
        //Clase que contiene las funciones de insercion, eliminar, modificar y busquedas por criterior
        clsReporteHoras ReporteHotas = new clsReporteHoras();
      
        private string gridMessage = null;


        protected void Page_Load(object sender, EventArgs e)
        {

            //Carga solamente la primera vez que se inicia la pagina, dejando los valores seleccionados despues de hacer otro postback
            if (!Page.IsPostBack)
            {
                        
               //Se inicializan los valores de fecha inicial y fecha final en la seccion de busqueda
               dpFechaInicio.SelectedDate = DateTime.Now.Date;
               string ls_dia = "";
               int li_numDia = 0;

               //Llena la lista de empleados
               LLenarEmpleados();

               //Usuario que se logeo en la aplicacion
               ddlConsultor.SelectedValue = "agondola";

               //LLena la lista de clientes
                LLenarClientes();
                
                //Llena la lista de proyectos dependiendo del cliente seleccionado
                llenarProyectos(Convert.ToInt32(ddlCLiente.SelectedValue));

                //Llena la lista de estados de las tareas del reporte
               // llenarEstadoTareas();

                //Permite asignar el rango de fecha al cual el usuario estara permitido a ingresar los reportes de hora
                 RangoFecha();

                //Permite cargar el grid de reporte de hora del empleado despendiendo de los criterios seleccionados
                //fLLenarGV();

                //Se utiliza para que se permita insertar, modificar y eliminar el registro en la misma fila
                 RadGrid1.MasterTableView.EditMode = GridEditMode.InPlace;

             }

        }


        /// <summary>
        /// Permite cargar la lista de reporte de hora del empleado despendiendo de los criterios seleccionados
        /// </summary>
        public void fLLenarGV()
        {

            try
            {

               DataSet dtsDatos = new DataSet();

               DataTable dt = new DataTable("TblRegistros");

               DataRow dr;

               int li_totalHoras = 0;

               //Limpia el label capturador de los errores
               lblMensajes.Style.Add("display", "");
               lblMensajes.Text = "";

               //Se le asigna al dataSet los valores recuperados del reporte de hora por los criterios seleccionados por el usuario  
               dtsDatos = ReporteHotas.Select_Reporte_Horas(Convert.ToString(ddlConsultor.SelectedValue), Convert.ToInt32(ddlCLiente.SelectedValue), Convert.ToInt32(dllProyecto.SelectedValue),
                          dpFechaInicio.SelectedDate.Value, dpFechaFin.SelectedDate.Value);

                //Se crea un datatable con los nombres de las columnas a desplegar en la lista de reportes de horas
                dt.Columns.Add("id_reporte");
                dt.Columns.Add("f_tarea");
                dt.Columns.Add("id_estado");
                dt.Columns.Add("descripcion_estado");
                dt.Columns.Add("descripcionTarea");
              
                dt.Columns.Add("cantidadHoraTarea");
                dt.Columns.Add("comando"); //campo utilizado para verificar si es un registro nuevo o un registro a actualizar


               //Se utiliza para agregar una nueva fila si no se recuperan datos en la consulta
               if( dtsDatos.Tables[0].Rows.Count == 0 ){
 
                   dr = dt.NewRow();
                   
                   //Se asignan valores a los registros para cargar el data table con informacion
                   dr["id_reporte"] = "";
                   dr["f_tarea"] = "";
                   dr["id_estado"] = "";
                   dr["descripcion_estado"] = "";
                   dr["descripcionTarea"] = "";
                  
                   dr["cantidadHoraTarea"] = "";
                   dr["comando"] = "N";  //campo utilizado para verificar si es un registro nuevo o un registro a actualizar

                   dt.Rows.Add(dr);
                
                    }

                else
               {
                   //Si devuelve registros se le asigna al campo comando: U, que significa que esa fila se actualizara
                   for (int i = 0; i < dtsDatos.Tables[0].Rows.Count; i++)
                   {

                       dr = dt.NewRow();

                       //Se asignan valores a los registros para cargar el data table con informacion
                       dr["id_reporte"] = dtsDatos.Tables[0].Rows[i]["id_reporte"];
                       dr["f_tarea"] = dtsDatos.Tables[0].Rows[i]["f_tarea"];
                       dr["id_estado"] = dtsDatos.Tables[0].Rows[i]["id_estado"];
                       dr["descripcion_estado"] = dtsDatos.Tables[0].Rows[i]["descripcion_estado"];
                       dr["descripcionTarea"] = dtsDatos.Tables[0].Rows[i]["descripcionTarea"];
               
                       dr["cantidadHoraTarea"] = dtsDatos.Tables[0].Rows[i]["cantidadHoraTarea"];

                       //Se calcula el total de horas trabajadas por el empleado, por los criterios selecionados
                       li_totalHoras = li_totalHoras + Convert.ToInt32(dtsDatos.Tables[0].Rows[i]["cantidadHoraTarea"]);

                       dr["comando"] = "U";   //campo utilizado para verificar si es un registro nuevo o un registro a actualizar

                       dt.Rows.Add(dr);

                   }

               }


               //Se asigna el DataTable al grid de "gvDatosReporte" para desplegar la lista de reportes del empleado por los criterios selecionados
                //gvDatosReporte.DataSource = dt;              
                //gvDatosReporte.DataBind();

                //gvDatosReporte.Visible = true;

                //Le asigno la suma de las horas trabajadas por el empleado a la caja de texto
                txtHorastrabajadas.Text = Convert.ToString(li_totalHoras);


                /////////////////////////////////
                //RadGrid1.DataSource = dt;
                //RadGrid1.DataBind();

                //RadGrid1.Visible = true;


                

            }
            catch (Exception ex)
            {
                lblMensajes.Style.Add("display", "");
                lblMensajes.Text = ex.Message;
            }

        }




        /// <summary>
        ///Se utiliza para cargar la lista de empleados
        /// </summary>
        public void LLenarEmpleados()
        {
            try
            {
                DataSet dtsDatos = new DataSet();

                //Se obtiene la lista de empleados
                dtsDatos = ReporteHotas.Select_Empleados();

                //Se carga el combo de consultor
                ddlConsultor.DataSource = dtsDatos;
                ddlConsultor.DataTextField = "nombre";
                ddlConsultor.DataValueField = "id_empleado";
                ddlConsultor.DataBind();

                ddlConsultor.SelectedIndex = 0;
            }

            catch (Exception ex)
            {

                lblMensajes.Style.Add("display", "");
                lblMensajes.Text = ex.Message;
            }
        }


    


        /// <summary>
        ///Se utiliza para cargar la lista de clientes
        /// </summary>
        public void LLenarClientes()
        {
            try
            {
                DataSet dtsDatos = new DataSet();

                //Se obtiene la lista de clientes             
                dtsDatos =  ReporteHotas.Select_Clientes();

                //Se carga el combo de clientes
                ddlCLiente.DataSource = dtsDatos;
                ddlCLiente.DataTextField = "nombre";
                ddlCLiente.DataValueField = "id_cliente";
                ddlCLiente.DataBind();

                ddlCLiente.SelectedIndex = 0;
            }

            catch (Exception ex)
            {

                lblMensajes.Style.Add("display", "");
                lblMensajes.Text = ex.Message;
             }
        }


        /// <summary>
        /// Se utiliza para cargar la lista de proyectos dependiendo el cliente seleccionado
        /// </summary>
        public void llenarProyectos(int li_id_cliente)
        {
            try
            {

                DataSet dtsDatos = new DataSet();

                //Se obtiene la lista de proyectos por el cliente seleccionado
                dtsDatos = ReporteHotas.Select_Proyectos(li_id_cliente);

                //Se carga el combo de proyecto
                dllProyecto.DataSource = dtsDatos;
                dllProyecto.DataTextField = "nombre";
                dllProyecto.DataValueField = "id_proyecto";
                dllProyecto.DataBind();

                dllProyecto.SelectedIndex = 0;

            }

            catch (Exception ex)
            {
                lblMensajes.Style.Add("display", "");
                lblMensajes.Text = ex.Message;
            }

        }




        /// <summary>
        /// Selecciona la lista de proyectos dependiendo del cliente seleccionado
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void ddlCLiente_SelectedIndexChanged(object sender, RadComboBoxSelectedIndexChangedEventArgs e)
        {
            try
            {
                //Se carga la lista de proyectos dependiendo el cliente seleccionado
                llenarProyectos(Convert.ToInt32(ddlCLiente.SelectedValue));

            }
            catch (Exception ex)
            {
                lblMensajes.Style.Add("display", "");
                lblMensajes.Text = ex.Message;
            }
        }

      

        /// <summary>
        /// Permite asignarle el rango de fecha inicio y fin para realizar la carga de reporte de horas
        /// </summary>
        public void RangoFecha ()
           {

             try
             {
            
            //controles de fecha
            string ls_dia = "";
            int li_numDia = 0;

            //Se escoje el nombre del dia para realizar el proceso de armar el rango de fecha inicial y rango de fecha final
            ls_dia = Convert.ToString(dpFechaInicio.SelectedDate.Value.DayOfWeek);

            switch (ls_dia)
            {
                case "Monday":

                    li_numDia = 0;

                    break;
                case "Tuesday":

                    li_numDia = -1;

                    break;
                case "Wednesday":

                    li_numDia = -2;

                    break;
                case "Thursday":

                    li_numDia = -3;

                    break;
                case "Friday":

                    li_numDia = -4;

                    break;
                case "Saturday":

                    li_numDia = -5;

                    break;
                case "Sunday":

                    li_numDia = -6;

                    break;
                default:
                    break;
            }

            //Rango inicial en la seccion de busqueda
            dpFechaInicio.SelectedDate = Convert.ToDateTime(dpFechaInicio.SelectedDate).AddDays(Convert.ToInt32(li_numDia));

            //Rango final en la seccion de busqueda
            dpFechaFin.SelectedDate = Convert.ToDateTime(dpFechaInicio.SelectedDate).AddDays(+6);
            
            //Fecha minima que se podra ingresar la tarea
            //RadGrid1.Item("id_reporte") = Convert.ToDateTime(dpFechaInicio.SelectedDate);

               
            //dpFecha.MinDate = Convert.ToDateTime(dpFechaInicio.SelectedDate);
            //Fecha maxima que se podra ingresar la tarea
            //dpFecha.MaxDate = Convert.ToDateTime(dpFechaFin.SelectedDate);

            }
            catch (Exception ex)
            {
                lblMensajes.Style.Add("display", "");
                lblMensajes.Text = ex.Message;
            }

    }

        /// <summary>
        /// Permite colocar el rango de fecha de inicio y fecha fin al cual el empleado puede ingresar las tareas
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void dpFechaInicio_SelectedDateChanged(object sender, SelectedDateChangedEventArgs e)
        {
            try
            {

                //Permite colocar el rango de fecha de inicio y fecha fin al cual el empleado puede ingresar las tareas
                RangoFecha();

            }
            catch (Exception ex)
            {
                lblMensajes.Style.Add("display", "");
                lblMensajes.Text = ex.Message;
            }
        }



        protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
        {
            Hashtable oldValues = new Hashtable();
            Hashtable newValues = new Hashtable();
            GridEditableItem editedItem = e.Item as GridEditableItem;
            oldValues = (Hashtable)editedItem.SavedOldValues;
            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, editedItem);
        }




        protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
        {


            GridEditableItem item = (GridEditableItem)e.Item;
            String id = Convert.ToString(item.GetDataKeyValue("id_reporte"));


            if (e.Exception != null)
            {
                e.KeepInEditMode = true;
                e.ExceptionHandled = true;
                SetMessage("Reporte con ID " + id + " no pudo ser actualizado. Razón: " + e.Exception.Message);
            }
            else
            {
                SetMessage("Reporte con ID " + id + " fue actualizado!");
            }
        }

        protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
        {

         
            if (e.Exception != null)
            {
                e.ExceptionHandled = true;
                SetMessage("La tarea no se puede insertar. Razón: " + e.Exception.Message);
            }
            else
            {
                SetMessage("La nueva tarea se inserto!");
            }
        }

        protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
        {
            GridDataItem dataItem = (GridDataItem)e.Item;
            String id =  Convert.ToString(dataItem.GetDataKeyValue("id_reporte"));


            if (e.Exception != null)
            {
                e.ExceptionHandled = true;
                SetMessage("Tarea con ID " + id + " no fue eliminada. Razón: " + e.Exception.Message);
            }
            else
            {
                SetMessage("Tarea con ID " + id + " fue eliminada!");
            }
        }





        private void DisplayMessage(string text)
        {
            RadGrid1.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text)));
        }

        private void SetMessage(string message)
        {
            gridMessage = message;
        }



        protected void RadGrid1_DataBound(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(gridMessage))
            {
                DisplayMessage(gridMessage);
            }
        }

        protected void RadGrid1_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {

            //fLLenarGV();


        }

    }
     
 }
Alexis
Top achievements
Rank 1
 asked on 20 Jun 2012
3 answers
389 views
Hi Telerik Team,

I have a radgrid with skin like Windows7 and I need to set a  border color to rows only in a radgrid.I tried as follows:

 

 

<telerik:RadGrid ID="rgLeaveType" runat="server" AutoGenerateColumns="False" CellSpacing="0"

 

 

 

AllowSorting="True" AllowFilteringByColumn="True" OnItemCommand="rgLeaveType_ItemCommand"

 

 

 

OnItemCreated="rgLeaveType_ItemCreated" OnItemDataBound="rgLeaveType_ItemDataBound"

 

 

 

OnNeedDataSource="rgLeaveType_NeedDataSource" Skin="Windows7" GridLines="Horizontal"

 

 

 

BorderColor="Red">

 


 

 

<telerik:GridButtonColumn FilterControlAltText="Filter column2 column" UniqueName="Delete"

 

 

 

Text="Delete" ConfirmText="Do you want to delete?" CommandName="Delete">

 

 

 

<HeaderStyle BorderColor="Red" />

 

 

 

<ItemStyle BorderColor="Red" />

 

 

 

</telerik:GridButtonColumn>

 


 

 

But I get border color to both rows and columns of the grid.How can I set border color to radgrid rows only.?
Thanks
Dayana

 

Pavlina
Telerik team
 answered on 18 Jun 2012
1 answer
90 views

Hi,
I want to maximize the rad window with the controls which are inside that window accordingly. pl reply me if anyone has solution for it.
Below code which i used is only maximize the window not the controls.

 

<

 

 

telerik:radwindow id="rdWndSearchHelp" IconUrl="~/Images/tis.gif" runat="server" width="319px" height="474px" navigateurl="SearchHelp.aspx" Behavior="Close,Move,Maximize,Minimize" ReloadOnShow="true" Skin="Vista" VisibleStatusbar="False" Modal="true">

 

 

 

</telerik:radwindow>
Regards
Ajeet

 

Marin Bratanov
Telerik team
 answered on 31 May 2012
1 answer
62 views
Hi,

Maximize the rad window but controls inside the window is not maximize, So how to achive this. please reply me if any one has the solution for it. code which I am using is given below...

<

 

 

telerik:radwindow id="rdWndSearchHelp" IconUrl="~/Images/tis.gif" runat="server" width="319px" height="474px" navigateurl="SearchHelp.aspx" Behavior="Close,Move,Maximize,Minimize" ReloadOnShow="true" Skin="Vista" VisibleStatusbar="False" Modal="true">

 

 

 

</telerik:radwindow>

 


Regards
Ajeet
Marin Bratanov
Telerik team
 answered on 31 May 2012
1 answer
99 views

Hi,
How to minimize the rad window pl anyone support me. I am using the following code but it is not working.

 

<

 

 

telerik:radwindow id="rdWndSearchHelp" IconUrl="~/Images/tis.gif" runat="server" width="319px" height="474px" navigateurl="SearchHelp.aspx" Behavior="Close,Move,Maximize,Minimize" ReloadOnShow="true" Skin="Vista" VisibleStatusbar="False" Modal="true">

 

after click on minimize icon Title bar shows on the screen.

Regards
Ajeet

Marin Bratanov
Telerik team
 answered on 31 May 2012
1 answer
136 views
Hello All,

1st Issue
I am currently using the 2012.1.215.40 version of the Telerik dlls.

I have one page having the iFrame in in. I am loading another page in this iframe having the user controls. Also that page has a master page which is dynamic master page that is I need to assign the master page dynamically to that page.

In that page I open RadWindow having the RadEditor in it but I am not able to click on any tool of the RadEditor. It is working with the Shortcut Keys but not working with the mouse clicks. Also it is working with the Safari browser but not working with the FireFox.

Another page have also same behavior but the difference is that I am opening the radeditor in the RadWindow but the it has beed given a target url that it is totally a different page so it is also working fine.

But if I try to use the RadWindow in the same control the this kind of problem happens.

2nd Issue
I am using the RadEditor and for the ImageManager tool I am creating the dynamic folders for the UploadPath and ViewPaths.
But when I click on Upload and upload the image if the folder is empty that is I am uploading the first image then image manager does not show any image uploaded. But if I close the window and then refresh the page and again open the Image manager then it shows the image which I have uploaded before. And then everything work properly that is I am able to upload other images after that but problem is just with the first image.

Hope for the proper solutions and suggestions.

Thanks to all
Hardik

Rumen
Telerik team
 answered on 24 May 2012
3 answers
90 views
Why doesn't the Winforms forum have a section for RadWindow? People are putting questions all over the place.
Thanks.
Nikolay
Telerik team
 answered on 23 May 2012
1 answer
98 views
I have to attach the radgrid header with a tooltip. I am using RadToolTipManager but I need a rounded corner instead of rectangle/square with a pointing mouse. in IE7.

CSS Class: 
.radtooltip_Default, .radtooltip_Default td, .radtooltip_Default tr
{
    background-color: Blue !important;
}

Aspx Page
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="TestTooltip.aspx.cs" Inherits="PriceRight.LaunchSequence.WebApplication.User.TestTooltip" %>

<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <link type="text/css" rel="stylesheet" media="all" href="../Resources/css/main.css" />  
    
  
    <meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
    <meta name="generator" content="HAPedit 3.1" />
    
   
</head>
<body>
    <form id="form1" runat="server">
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <br />
    <div id="zone">
        <table>
            <tr>
                <td>
                    <asp:Label ID="Label1" Text="Below is the data table" runat="server" Font-Size="Larger"></asp:Label>
                </td>
                <td>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
                <td>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </td>
            </tr>
        </table>
        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
        <table>
            <tr>
                <td>
                    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
                    </telerik:RadScriptManager>
                    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="false" OnItemDataBound="RadGrid1_ItemDataBound">
                        <MasterTableView ShowHeadersWhenNoRecords="true">
                            <Columns>
                                <telerik:GridBoundColumn DataField="ABC" HeaderText="ABC">
                                </telerik:GridBoundColumn>
                            </Columns>
                        </MasterTableView>
                    </telerik:RadGrid>
                </td>
            </tr>
        </table>
    </div>
   
    <telerik:RadToolTipManager ID="RadToolTipManager2" runat="server" AutoTooltipify="true"
        RelativeTo="Mouse" Position="TopCenter" ContentScrolling="Default" Width="150"
        EnableShadow="false" Height="10" ToolTipZoneID="zone">
    </telerik:RadToolTipManager>
   
    </form>
</body>
</html>
 TestTooltip .aspx.cs Page
public partial class TestTooltip : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            RadGrid1.DataSource = createDataTable();
        }


        protected void RadGrid1_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item.ItemType == GridItemType.Header)
            {
                GridHeaderItem item = e.Item as GridHeaderItem;
                foreach (TableCell cell in item.Cells)
                {
                    cell.ToolTip = "I am a textbox with some other very very very very very very long tooltip.Text";


                    // cell.ToolTip.
                    // cell.CssClass = "ToolTipContent";
                    // cell.ToolTip
                    //if ((cell.Controls.Count > 0))
                    //{
                    //    // add tooltip to header title link
                    //    RadToolTipManager1.TargetControls.Add(cell.ClientID, true);
                    //}
                }
            }
        }


        private DataTable createDataTable()
        {
            DataTable dt = new DataTable();
            dt.Columns.Add("ABC");
            dt.Columns.Add("Column2");
            DataRow dr = dt.NewRow();
            dr["ABC"] = "Column1 - Row 1";
            dr["Column2"] = "Column2 - Row 1";
            dt.Rows.Add(dr);


            return dt;
        }
    }

Please provide me  a solution.

Thanks,
Kiti




Bozhidar
Telerik team
 answered on 21 May 2012
1 answer
82 views
Hi 

Is there an option to display a radgrid table in a vertical format e.g.


Customer: McDonalds
Address: 1 McDonald Road
Postcode: MC1 2DV

instead of currently

Customer Address Postcode
McDonalds 1 McDonald Road MC1 2DV

Kind regards

Rob 
Eyup
Telerik team
 answered on 21 May 2012
1 answer
93 views
My daily RadControls experience consists of:
  • do the best I can
  • when I have a question, come to the forum
  • check demos
  • once in a while check videos and code samples
  • contact Support
  • in desperation, consult documentation pages
  • repeat as required
I prefer not to contact Support simply because I don't want to waste their time. Telerik Support personnel are stellar! They know their product and the technology, they're cordial, and communicate effectively. But Support can take a day or two to respond too. When I'm stuck on an issue, I need to resolve it ASAP.
 
I do prefer to post to the forum, so that everyone can benefit from information found there. The problem with the forum is that responses aren't guaranteed, they're not guaranteed to be accurate, and they are not as timely as Support.

Notice consulting documentation is on the bottom. I'm sorry but the website docs don't provide insight. The info there is basic documentation. I'm often left understanding a single function, but in the overall plan, unless I know I need that specific function it's frequently a long journey to get there. Like most docs, that material is for reference, not tutorial.

For tutorials and training, I know there is Telerik TV, all the vids, Trainer, and Falafel and other services. There is also one decent (but old) book that's easily available, and a newer one published within the last year or two.

But every day, with all of this material available, I'm still finding myself in the forum doing searches - as much time there as I might spend in Google.

So the question is : How do we get to Ninja status? Is there a book or "insiders' newsletter" that really goes deep on these controls to fully explore various nuances?
- I want to see a diagram of how the grid is laid out, where CSS is applied, and what options are available at every tier. I don't want to have to hunt to figure out which object in the grid exposes some property.
- I want to get total immersion into the why's and how's of client side development so that I can ween myself away from server-centric development and some of the headaches of postbacks.
- I want to be completely in tune with the exact state of controls at each stage of the ASP.NET life cycle, so that I'm not surprised when I see control events firing, and so that I can pro-actively prevent rogue event firing rather than using e.Cancel.

This product is so deep. A class would take a couple weeks, travel, and a huge expense. Given a large budget and a lot of "free" time (laughing too hard here) I'd prefer a book like "RadControls Unleashed" or "Telerik Inside and Out". I wish we could pick a topic, start a discussion with a Telerik developer, and carry on the discussion over a period of weeks to completely absorb what that person has in his or her head. Then move on to the next topic. Then when people have a question in the forum send them to this brain dump before posting a hundred random responses, with dead-end discussions, or isolated details about the product.

OK, I'm done now. You get the idea. :)

Thanks for any responses!
Rumen
Telerik team
 answered on 11 May 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Edmond
Top achievements
Rank 1
Iron
fabrizio
Top achievements
Rank 2
Iron
Veteran
RobMarz
Top achievements
Rank 2
Iron
Fakhrul
Top achievements
Rank 1
Iron
Tejas
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?