This is a migrated thread and some comments may be shown as answers.

[Solved] Get Control of TemplateForm of Grid

1 Answer 80 Views
Grid
This is a migrated thread and some comments may be shown as answers.
VM2
Top achievements
Rank 2
VM2 asked on 28 Aug 2009, 12:43 PM
Hi,

   I Need Validation controls at TemplateForm of Grid using Custom Validators. How get the controls by javasript function?

<EditFormSettings ColumnNumber="2" CaptionDataField="CodigoProduto"  CaptionFormatString="Edit properties of Product {0}">                                                 
                                                <FormTemplate> 
                                                    <table style="width:100%;">  
                                                        <tr> 
                                                            <td><asp:Label ID="lblProduto" runat="server" Text="Código do produto:" CssClass="cad-lbl" /></td>  
                                                            <td colspan="5">  
                                                                <asp:TextBox ID="txtProdutoCodigo" runat="server" ReadOnly="true"></asp:TextBox> 
                                                                <asp:HiddenField ID="hdfProdutoCodigo" runat="server"   
                                                                    onvaluechanged="hdfProdutoCodigo_ValueChanged" /> 
                                                                  
                                                                <button onclick="openWin(); return false;" class="btn">  
                                                                    Buscar</button>   
                                                            </td>                                                              
                                                        </tr> 
                                                        <tr> 
                                                            <td> 
                                                                <asp:Label ID="lblQuantidade" runat="server" Text="Quantidade (m):" CssClass="cad-lbl"/>  
                                                                <asp:RequiredFieldValidator ID="rfvQuantidade" ValidationGroup="Produto" runat="server" 
                                                                    ControlToValidate="ntxtQuantidade" ErrorMessage="O campo Quantidade Ã© obrigatório." 
                                                                    Text="*"></asp:RequiredFieldValidator> 
                                                            </td> 
                                                            <td> 
                                                                <vm2:NumericTextBox ID="ntxtQuantidade" runat="server" MinValue="0" onblur="onblurQuantidade()"  CssClass="cad-txt" EnableEmbeddedSkins="false" Skin=""/>                                      
                                                            </td> 
                                                            <td> 
                                                                <asp:Label ID="lblLances" runat="server" Text="Lances:" CssClass="cad-lbl"></asp:Label> 
                                                                <asp:RequiredFieldValidator ID="rfvLances" ValidationGroup="Produto" runat="server" 
                                                                    ControlToValidate="ntxtLances" ErrorMessage="O campo Lances Ã© obrigatório." Text="*"></asp:RequiredFieldValidator> 
                                                            </td> 
                                                            <td> 
                                                                <vm2:NumericTextBox ID="ntxtLances" NumberFormat-DecimalDigits="0" onblur="onblurLance()" 
                                                                    runat="server" MinValue="0"  CssClass="cad-txt" EnableEmbeddedSkins="false" Skin=""/>  
                                                            </td> 
                                                            <td> 
                                                                <asp:Label ID="lblMetragem" runat="server" Text="Metragem:" CssClass="cad-lbl"></asp:Label> 
                                                            </td> 
                                                            <td> 
                                                                <asp:TextBox ID="txtMetragem" runat="server" ReadOnly="true" CssClass="cad-txt"></asp:TextBox> 
                                                                <asp:HiddenField ID="hdfMetragem" runat="server" /> 
                                                            </td> 
                                                        </tr> 
                                                        <tr> 
                                                            <td> 
                                                                <asp:Label ID="lblPrecoAplicado" runat="server" Text="Preço Aplicado:" CssClass="cad-lbl"></asp:Label> 
                                                            </td> 
                                                            <td> 
                                                                <asp:TextBox ID="txtPrecoAplicado" runat="server" ReadOnly="true" CssClass="cad-txt"></asp:TextBox> 
                                                                <asp:HiddenField ID="hdfPrecoAplicado" runat="server" /> 
                                                            </td> 
                                                            <td> 
                                                                <asp:Label ID="lblAcondicionamento" runat="server" Text="Acondicionamento:" CssClass="cad-lbl"></asp:Label> 
                                                                <asp:CompareValidator ID="cpvAcondicionamento" runat="server" ValueToCompare="-- Selecione --" 
                                                                ValidationGroup="Produto" ControlToValidate="ddlAcondicionamento" Operator="NotEqual" 
                                                                ErrorMessage="O campo Acondicionamento Ã© obrigatório." Text="*"></asp:CompareValidator>                      
                                                            </td> 
                                                            <td> 
                                                                <vm2:Combobox ID="ddlAcondicionamento" runat="server" Skin="Office2007" CssClass="cad-ddl" 
                                                                    ZIndex="9000" OnItemDataBound="ddlAcondicionamento_ItemDataBound">  
                                                                </vm2:Combobox> 
                                                            </td> 
                                                            <td colspan="2">  
                                                                <asp:Button ID="btnAdicionarProduto" runat="server" Text="Adicionar" ValidationGroup="Produto" 
                                                                    OnClick="btnAdicionarProduto_Click" CssClass="btn" /> 
                                                            </td>                                                              
                                                        </tr>                                                          
                                                    </table> 
                                                </FormTemplate> 
                                            </EditFormSettings> 

1 Answer, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 31 Aug 2009, 06:59 AM
Hello,

You can go through the following code library submission link which demonstrates how to access GridTemplate Controls on the client side.
Accessing server controls in a grid template on the client

You can also go through the following code library submission link which demonstrates how to store the client id of the control editor in window object attribute (global scope variable) and then trace the control on the client using the document.getElementById(id) method.
Retrieving grid editor value client side

Thanks
Princy.
Tags
Grid
Asked by
VM2
Top achievements
Rank 2
Answers by
Princy
Top achievements
Rank 2
Share this question
or