how to get the hidden column value

9 posts, 0 answers
  1. Kranthi
    Kranthi avatar
    9 posts
    Member since:
    Jul 2012

    Posted 06 Jul 2012 Link to this post

    Hi All

    i have a requirement to get the hidden column value for the rows which checkbox has been selected, can anyone come up with a good solution to complete this thing  may be client side or server side ... 

    my rad grid 

                <telerik:RadGrid ID="M" runat="server" Width="99%" AllowPaging="True" EnableViewState="False"
                    GridLines="None" meta:resourcekey="MResource1" AllowFilteringByColumn="true"
                    OnInit="GridControl_Init" EnableLinqExpressions="false" 
                    EnableEmbeddedSkins="false" AutoGenerateColumns="False">
                    <HeaderContextMenu EnableEmbeddedSkins="True">
                    <FilterMenu Skin="Nediso" EnableEmbeddedSkins="false">
                    <PagerStyle Mode="NextPrevAndNumeric" Position="TopAndBottom" AlwaysVisible="true" />
                    <MasterTableView Width="100%" EnableViewState="False" AllowFilteringByColumn="true">

                       <telerik:GridTemplateColumn UniqueName="CheckBoxTemplateColumn" AllowFiltering="false">
                       <HeaderStyle Width="3%" HorizontalAlign="Justify" />
                        <ItemStyle Width="3%" HorizontalAlign="Justify" />
                                 <asp:CheckBox id="headerChkbox"  runat="server" onclick="SelectAll(this)"></asp:CheckBox>
                                    <asp:CheckBox id="CheckBox1" runat="server"></asp:CheckBox>
                         <telerik:GridBoundColumn DataField="TOKEN" Visible="false" UniqueName="TOKEN" ReadOnly="true" >
                        <telerik:GridBoundColumn DataField="FIRST NAME" HeaderText="FIRST NAME" UniqueName="FIRST NAME">
                        <telerik:GridBoundColumn DataField="LAST NAME" HeaderText="LAST NAME" UniqueName="LAST NAME">
                        <telerik:GridBoundColumn DataField="STATUS" HeaderText="STATUS" UniqueName="STATUS">
                        <telerik:GridBoundColumn DataField="DESIGNATION" HeaderText="DESIGNATION" UniqueName="DESIGNATION">
                        <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric" Position="TopAndBottom" />
                    <ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True" EnableRowHoverStyle="True">
                        <Resizing AllowColumnResize="True" />
                        <Selecting AllowRowSelect="True" />                    
                        <ClientEvents OnFilterMenuShowing="OnFilterMenuShowing"></ClientEvents> 
                    <FilterMenu EnableTheming="True">
                        <CollapseAnimation Type="None" />
                        <ExpandAnimation Type="None" />

  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 09 Jul 2012 Link to this post


    One suggestion is you can set the Display property of the column as false and then get the column value. Try the following javascript to acess hidden column value.
    <telerik:GridBoundColumn UniqueName="EmployeeID" Display="false"  DataField="EmployeeID" HeaderText="EmployeeID">
    function check() {
     var grid = $find("<%=RadGrid1.ClientID %>");
     var masterTable = grid.get_masterTableView();
     var row = masterTable.get_dataItems()[0];
     var cell = masterTable.getCellByColumnUniqueName(row, "TOKEN");

  3. Kostadin
    Kostadin avatar
    1733 posts

    Posted 09 Jul 2012 Link to this post

    Hello Kranthi,

    You can also do it by leaving the Visible property to false. For this purpose you should add the following javascript:

    function RowSelected(sender, eventArgs) {
                var grid = sender;
                var MasterTable = grid.get_masterTableView();
                var row = MasterTable.get_dataItems()[eventArgs.get_itemIndexHierarchical()];
                var cell = row.getDataKeyValue("TOKEN");
                //here cell.innerHTML holds the value of the cell  

    You should also add ClientDataKeyNames property in MasterTableView.

    <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" ClientDataKeyNames="TOKEN">

    You will find more information here:

    All the best,
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  4. Adam
    Adam avatar
    17 posts
    Member since:
    Sep 2012

    Posted 05 Mar 2014 Link to this post

    How can I do this server-side..??  I have a number of hidden fields..

    I can't seem to get the text value other than "&nbsp;"

    I've just upgraded from version 2011.x to 2013.3.1324.45..  my previous code no longer seems to work as expected. :

    1.For Each i As GridDataItem In grdItems.MasterTableView.GetSelectedItems()
    2.  If i.Selected Then
    3.    Dim iVal As GridDataItem = i
    4.    Dim IDVal as string = iVal("MER_ItemSummaryID").Text
    6.  end if

    I've set the DataKeyNames value for the MasterTableView and can get the value using :

    This returns : "{MER_ItemSummaryID:"21694"}"

    I thought there might be a nicer way to retrieve them than parsing a text value.


  5. Adam
    Adam avatar
    17 posts
    Member since:
    Sep 2012

    Posted 05 Mar 2014 in reply to Adam Link to this post

    Sorry..  I hate it when you search for hours for a solution, you end up finally just posting to a forum like this one or SO, then literally 5 minutes later find the solution you require..

    I just changed my code slightly to the following:

    For Each i As GridDataItem In grdItems.MasterTableView.GetSelectedItems()
        If i.Selected Then
            Dim iVal As GridDataItem = i
            Dim IDVal as string = iVal.GetDataKeyValue("MER_ItemSummaryID").ToString()
        End If

  6. Princy
    Princy avatar
    17421 posts
    Member since:
    Mar 2007

    Posted 06 Mar 2014 in reply to Adam Link to this post

    Hi Adam,

    If you have hidden columns for your grid, you can access them in the code-behind either through DataKeyValue or if you set the Display as false you may access the columns in server side. Please take a look at the below code.

    <MasterTableView DataKeyNames="OrderID">
      <telerik:GridBoundColumn DataField="ShipCity" HeaderText="ShipCity" UniqueName="ShipCity" Display="false" />  

    If TypeOf e.Item Is GridDataItem Then
        Dim items As GridDataItem = DirectCast(e.Item, GridDataItem)
        Dim id As String = items.GetDataKeyValue("OrderID").ToString()
        Dim value As String = items("ShipCIty").Text
    End If

  7. Amjad
    Amjad avatar
    36 posts
    Member since:
    Dec 2010

    Posted 23 Nov 2014 in reply to Princy Link to this post

    I have this problem that when  I get the hidden field value it returns &nbsp; when its empty.

    how can I get around this issue?

    please note that I can put if statement to avoid this but I need better solution
  8. Kostadin
    Kostadin avatar
    1733 posts

    Posted 26 Nov 2014 Link to this post

    Hi Amjad,

    Note that when a columns is hidden by setting Visible to false it will set &nbsp; text to its cell. I am afraid if you need to remove it you have to manually do that on ItemDataBound event handler by checking the cell text.


    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

  9. Christophorus Donny
    Christophorus Donny avatar
    3 posts
    Member since:
    Jun 2016

    Posted 24 Aug 2017 Link to this post

    don't use Visible="false" on your GridBoundColumn/GridNumericColumn.
    try this to hidden your collumn and still get the value :
    RadGrid1.MasterTableView.GetColumn("UniqueName").Display = False

Back to Top