Search RadTextbox of a RadGrid

1 posts, 0 answers
  1. Alonso
    Alonso avatar
    1 posts
    Member since:
    Apr 2018

    Posted 27 Apr 2018 Link to this post

    In an Edit Form Template of a RadGrid, I have a LinkButton and when that control is pressed a RadWindow is shown, that RadWindow has another RadGrid with a Select column, when the user presses that column, the system must take the value of another column and return it to a RadTextbox of the parent RadGrid.

    This is my current code, but it does not work, I can not find the RadTextbox of the RadGrid parent.

    <telerik:RadGrid ID="RgvUsuario" runat="server" RenderMode="Lightweight" AllowSorting="true" AutoGenerateColumns="false" AllowPaging="true" PageSize="10"
                    OnNeedDataSource="RgvUsuario_NeedDataSource" OnItemDataBound="RgvUsuario_ItemDataBound">
                    <MasterTableView DataKeyNames="Id" CommandItemDisplay="Top" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" AlternatingItemStyle-HorizontalAlign="Center">
                        <CommandItemSettings AddNewRecordText="Nuevo" ShowRefreshButton="false" />
                        <PagerStyle AlwaysVisible="true" />
                        <Columns>
                            <telerik:GridEditCommandColumn UniqueName="EditCommandColumn" ButtonType="ImageButton" EditText="Editar"></telerik:GridEditCommandColumn>
     
                            <telerik:GridBoundColumn DataField="Id" HeaderText="Id Usuario" UniqueName="Id"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="IdCliente" HeaderText="Id Cliente" UniqueName="IdCliente"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Nombre" HeaderText="Nombre" UniqueName="Nombre"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Apellido1" HeaderText="Apellido 1" UniqueName="Apellido1"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Apellido2" HeaderText="Apellido 2" UniqueName="Apellido2"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="UserName" HeaderText="UserName" UniqueName="UserName"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Identificacion.Numero" HeaderText="Identificación" UniqueName="Identificacion.Numero"></telerik:GridBoundColumn>
                            <telerik:GridBoundColumn DataField="Telefono.NumTelefono" HeaderText="Teléfono" UniqueName="Telefono.NumTelefono"></telerik:GridBoundColumn>
                            <telerik:GridCheckBoxColumn DataField="IsActivo" HeaderText="Estado" UniqueName="IsActivo"></telerik:GridCheckBoxColumn>
     
                            <telerik:GridButtonColumn ConfirmText="¿Eliminar registro?" ConfirmDialogType="RadWindow" ButtonType="ImageButton"
                                ConfirmTitle="Mantenimiento de Usuarios" CommandName="Delete" Text="Eliminar" UniqueName="DeleteColumn">
                            </telerik:GridButtonColumn>
                        </Columns>
                        <EditFormSettings EditFormType="Template">
                            <FormTemplate>
                                <table class="grid-edit-form">
                                    <tr>
                                        <td colspan="6"><span class="negrita">Detalle del Usuario</span></td>
                                    </tr>
     
                                    <%--Fila 1--%>
                                    <tr>
                                        <%--Columna 1--%>
                                        <td>Id Cliente</td>
                                        <td>
                                            <telerik:RadTextBox ID="txtIdCliente" Text='<%# Eval("IdCliente") %>' runat="server"></telerik:RadTextBox>
                                            <br />
                                            <asp:LinkButton ID="LnkBtnBuscarCliente" runat="server" ToolTip="Buscar Cliente" OnClick="LnkBtnBuscarCliente_Click">Buscar Cliente</asp:LinkButton>
                                        </td>
     
                                        <%--Columna 2--%>
                                        <td>Nombre</td>
                                        <td>
                                            <telerik:RadTextBox ID="txtNombre" Text='<%# Eval("Nombre") %>' runat="server" MaxLength="100"></telerik:RadTextBox>
                                        </td>
     
                                        <%--Columna 3--%>
                                        <td>Apellido 1</td>
                                        <td>
                                            <telerik:RadTextBox ID="Apellido1" Text='<%# Eval("Apellido1") %>' runat="server" MaxLength="100"></telerik:RadTextBox>
                                        </td>
                                    </tr>
     
                                    <tr>
                                        <%--Columna 1--%>
                                        <td colspan="2"> </td>
     
                                        <%--Columna 2--%>
                                        <td colspan="2"> </td>
     
                                        <%--Columna 3--%>
                                        <td colspan="2" class="derecha">
                                            <telerik:RadButton ID="btnAgregar" runat="server" Text='<%# (Container is GridEditFormInsertItem) ? "Agregar" : "Modificar" %>' CommandName="Update"
                                                RenderMode="Lightweight" EnableEmbeddedSkins="false" Width="100px" Height="40px">
                                            </telerik:RadButton>
                                              
                                            <telerik:RadButton ID="RbtnCancelar" runat="server" Text="Cancelar" CausesValidation="false" CommandName="Cancel" RenderMode="Lightweight"
                                                EnableEmbeddedSkins="false" Width="100px" Height="40px">
                                            </telerik:RadButton>
                                        </td>
                                    </tr>
                                </table>
                            </FormTemplate>
                        </EditFormSettings>
                    </MasterTableView>
                    <ClientSettings AllowKeyboardNavigation="true" EnableRowHoverStyle="true">
                        <ClientEvents OnRowDblClick="RowDblClick"></ClientEvents>
                    </ClientSettings>
                </telerik:RadGrid>
                 
    <telerik:RadWindow RenderMode="Lightweight" ID="RwBuscarCliente" runat="server" OpenerElementID="RgvUsuario" Title="Búsqueda de Datos"
            CenterIfModal="true" Modal="true" OffsetElementID="main" Height="400px" Behaviors="Close" Width="800px" EnableShadow="true">
            <ContentTemplate>
                <telerik:RadAjaxPanel ID="RadAjaxPanel2" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
                    <div class="ws-normal">
                        <telerik:RadGrid ID="gdvCliente" runat="server" RenderMode="Lightweight" AllowSorting="true" AutoGenerateColumns="false" AllowPaging="true" PageSize="10"
                            OnNeedDataSource="gdvCliente_NeedDataSource" OnItemCommand="gdvCliente_ItemCommand">
                            <MasterTableView DataKeyNames="Id" CommandItemDisplay="None" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Justify" AlternatingItemStyle-HorizontalAlign="Justify">
                                <PagerStyle AlwaysVisible="true" />
                                <Columns>
                                    <telerik:GridBoundColumn DataField="Id" HeaderText="Id" UniqueName="Id"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="Nombre" HeaderText="Nombre" UniqueName="Nombre"></telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn DataField="NombreComercial" HeaderText="Nombre Comercial" UniqueName="NombreComercial"></telerik:GridBoundColumn>
                                     
                                    <telerik:GridButtonColumn Text="Selecccionar" UniqueName="SelectColumn" CommandName="Select" ButtonType="LinkButton"></telerik:GridButtonColumn>
                                </Columns>
                            </MasterTableView>
                            <ClientSettings AllowKeyboardNavigation="true" EnableRowHoverStyle="true"></ClientSettings>
                        </telerik:RadGrid>
                    </div>
                </telerik:RadAjaxPanel>
            </ContentTemplate>
        </telerik:RadWindow>
    private string Fila
            {
                get { return (string)ViewState["Fila"]; }
                set { ViewState["Fila"] = value; }
            }
     
    protected void LnkBtnBuscarCliente_Click(object sender, EventArgs e)
            {
                CargarGridCliente(); <-- Load the information in the RadGrid of the RadWindow
                 
                RwBuscarCliente.VisibleOnPageLoad = true;
     
                GridEditableItem edit = (GridEditableItem)((LinkButton)sender).NamingContainer;
                this.Fila = edit.ItemIndex.ToString();
            }
             
    protected void gdvCliente_ItemCommand(object sender, GridCommandEventArgs e)
            {
                if (e.CommandName.Equals("Select"))
                {
                    GridDataItem item = (GridDataItem)e.Item;
                    string idCliente = item["Id"].Text;
     
     
                    int currentIndex = Convert.ToInt16(this.Fila);
                    GridEditFormItem form = RgvUsuario.Items[currentIndex].EditFormItem;
                    RadTextBox txtIdCliente = form.FindControl("txtIdCliente") as RadTextBox;
                     
                    txtIdCliente.Text = idCliente;
     
                    RwBuscarCliente.VisibleOnPageLoad = false;
                }
            }
Back to Top