Retrieving grid editor value client side

Thread is closed for posting
3 posts, 1 answers
  1. 63F75A2C-1F16-4AED-AFE8-B1BBD57646AD
    63F75A2C-1F16-4AED-AFE8-B1BBD57646AD avatar
    1572 posts
    Member since:
    Oct 2004

    Posted 26 Jul 2006 Link to this post



    RadGrid for ASP .NET version

    RadControls for ASP .NET AJAX version

    3.5.1 and later

    2008.1.415 and later

    .NET version

    2.0 and later

    Visual Studio version

    2005 and later

    Programming language

    VB.NET, Javascript

    Browser support

    all supported by RadGrid for ASP .NET

    all browsers supported by RadControls for ASP .NET AJAX


    The demo illustrates how to access the Country field editor value (pressing a button and wiring its onclick event) when item is in edit/insert mode. Note that we store the client id of the textbox editor in window object attribute (global scope variable) and then trace the textbox on the client calling the document.getElementById(id) javascript method.

    Note: the example uses WebUserControl custom edit form, however the same technique is applicable with for FormTemplate or auto-generated edit forms (with slight modifications in the code).

    Below is an the modification required when using FormTemplate custom edit form:

    Protected Sub RadGrid1_ItemCreated(ByVal sender As ObjectByVal e As Telerik.WebControls.GridItemEventArgs) Handles RadGrid1.ItemCreated  
            If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then 
                Dim editFormItem As GridEditFormItem = CType(e.Item, GridEditFormItem)  
                Dim box As TextBox = editFormItem.FindControl("TextBox1")  
                RadGrid1.Controls.Add(New LiteralControl("<script type='text/javascript'>window['CountryBoxId'] = '" & box.ClientID & "';</script>"))  
            End If 
    End Sub 
  2. Answer
    48D98628-C407-43BE-AAC3-DD18CB409DBB avatar
    13 posts
    Member since:
    Oct 2008

    Posted 22 Dec 2008 Link to this post

    i try the Examples but its not working javascript value throw null alert

    its my coding
    Protected Sub RadGrid1_ItemCreated(ByVal sender As ObjectByVal e As Telerik.WebControls.GridItemEventArgs) Handles RadGrid1.ItemCreated  
            If (TypeOf e.Item Is GridEditFormItem AndAlso e.Item.IsInEditMode) Then 
                Dim editFormItem As GridEditFormItem = CType(e.Item, GridEditFormItem)  
                Dim box As TextBox = editFormItem.FindControl("txtName")  
                RadGrid1.Controls.Add(New LiteralControl("<script type='text/javascript'>window['NameId'] = '" & box.ClientID & "';</script>"))  
            End If 
    End Sub 

    <script language="javascript" type="text/javascript">
    function GetValue()
                  var Names= document.getElementById(window['NameId']);
                    alert("no item in edit/insert mode available");
                    return false;
                    alert("Title edited value is: " + Names.value);

    aspx  custom  Editable grid

    <EditFormSettings  EditFormType="Template"  >
                                                <FormTableItemStyle Wrap="False"></FormTableItemStyle>
                                                <FormCaptionStyle CssClass="RadGridHeader"></FormCaptionStyle>
                                                <FormMainTableStyle BackColor="White" GridLines="Horizontal" CellPadding="3" Width="100%" CellSpacing="0"></FormMainTableStyle>
                                                <FormTableStyle CellSpacing="0" CellPadding="2" CssClass="module" Height="110px" BackColor="White" />
                                                <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                                                <EditColumn CancelText="Cancel edit" InsertText="Insert Order"  UniqueName="EditCommandColumn1" ButtonType="ImageButton" UpdateText="Update record">
                                                <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                                                    <FormTemplate >
                                                        <table cellpadding="0"  cellspacing="0" width="100%" border="0">
                                                            <tr><td style="height:3px;" colspan ="2"></td></tr>
                                                                <td align="right" colspan="2">
                                                                    <asp:ImageButton ID="btnUpdate" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>' ImageUrl="~/Images/icons/Update.gif"
                                                                    runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>' OnClientClick="return fn_GetValue()">
                                                                    <asp:ImageButton ID="Button1" Text="Cancel" runat="server" CausesValidation="False" ImageUrl="~/Images/icons/CancelEdit.gif"
                                                                    CommandName="Cancel" OnClientClick="DeleteHiddenvalue()"></asp:ImageButton>
                                                                <td >
                                                                   <asp:TextBox ID="txtName" runat="server" EnableTheming ="true" Text='<%#Eval("name") %>' ></asp:TextBox>&nbsp;                  </td>


  3. C7498A83-7E2E-418C-8791-93EF573A7569
    C7498A83-7E2E-418C-8791-93EF573A7569 avatar
    9934 posts
    Member since:
    Nov 2016

    Posted 22 Dec 2008 Link to this post

    Hello Ravi,

    Can you please verify that the demos attached to this code library thread work as expected on your machine? If you experience difficulties in converting the code for your particular configuration, please prepare a small working version of your project, illustrating the erroneous behavior, and send it attached to a formal support ticket. We will examine your complete code logic and will advice you further.

    Kind regards,
    the Telerik team

    Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Back to Top

This Code Library is part of the product documentation and subject to the respective product license agreement.