Accessing Readonly/Hidden Fields in Edit Mode (GridEditFormItem.OwnerTableView.DataKeyValues(item.ItemIndex) method)

Thread is closed for posting
1 posts, 0 answers
  1. E36DB7A2-AB32-42FF-AF45-B5F5144BDE1A
    E36DB7A2-AB32-42FF-AF45-B5F5144BDE1A avatar
    3 posts
    Member since:
    Feb 2010

    Posted 27 Dec 2012 Link to this post

    Requirements

    RadControls version 2012.3.1205.40
    .NET version v4.0.30319
    Visual Studio version 2010SP1
    programming language VB.NET
    browser support

    all browsers supported by RadControls


    PROJECT DESCRIPTION
    This project demonstrates how to access readonly/hidden values in a RadGrid while in edit mode with WebUserControl edit form.

    The column is defined in the RadGrid as such:

    <telerik:RadGrid ID="grid" runat="server" AutoGenerateColumns="False" ShowStatusBar="true" CssClass="RadGrid">
        <MasterTableView Width="100%" DataKeyNames="BookID" PagerStyle-PageSizes="50">
            <Columns>
                <telerik:GridEditCommandColumn UniqueName="editcol" ButtonType="ImageButton" />
                <telerik:GridBoundColumn UniqueName="BookID" ReadOnly="true" HeaderText="Book ID" DataField="BookID" />
                <telerik:GridBoundColumn UniqueName="BookName" HeaderText="Book Name" DataField="BookName" />
            </Columns>
            <EditFormSettings UserControlName="BookEditor.ascx" EditFormType="WebUserControl">
                <EditColumn UniqueName="EditCommandColumn1" />
            </EditFormSettings>
        </MasterTableView>
    </telerik:RadGrid>

    It may be accessed in the code behind using the following syntax:

    Private Sub grid_UpdateCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles grid.UpdateCommand
     
        Dim item As GridEditFormItem = DirectCast(e.Item, GridEditFormItem)
     
        ' accessing the readonly column
        Dim BookID As String = item.OwnerTableView.DataKeyValues(item.ItemIndex)("BookID").ToString()


    Please note that in the attached zip file, the Telerik.Web reference is removed to allow for a smaller upload. Please add it back to allow the project to function.
Back to Top

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