RadGrid, extracting KeyID of a row selected

Posted on 2009-04-23
Last Modified: 2012-05-06
Based on the code snipets, I keep getting the message "get_.... is null or not an object.

I have tried a number of differeent calls but can not seem to get at the key values for the rows I have selected.

Any Thoughts?
function RowSelected(sender, args) {

                        var CRS = args.get_gridDataItem().get_dataItem()["CrsID"];



                            <telerik:RadGrid ID="courseContent" runat="server" Width="273" ItemStyle-Wrap="true"

                                  Height="300" AllowMultiRowSelection="true" AllowMultiRowEdit="true" gridlines="None"  OnRowDrop="courseContent_RowDrop" 

                                  Skin="WebBlue" OnNeedDataSource="courseContent_NeedDataSource" AllowAutomaticDeletes="true" OnDeleteCommand="courseContent_DeleteCommand">

                                <MasterTableView DataKeyNames="CrsID" CommandItemDisplay="None" HorizontalAlign="Center" 

                                  HeaderStyle-BorderWidth="0" ItemStyle-BorderWidth="0" FooterStyle-BorderWidth="0"  

                                  AutoGenerateColumns="False" Width="100%" BorderWidth="0">


                                        <telerik:GridBoundColumn  UniqueName="CrsID" datafield="CrsID" Visible="false"></telerik:GridBoundColumn>

                                        <telerik:GridTemplateColumn HeaderStyle-Font-Size="8" HeaderText="Current Student Profile Contents" UniqueName="crsNumber">


                                               <asp:Label ID="lblCourseNumber" ForeColor="#333333" Font-Names="arial" Font-Size="9"  Text='<%# Databinder.Eval(Container.DataItem,"crsnumber")%>'

                                                Width="225px" runat="server" BorderWidth="0">




                                        <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="../skins/webblue/grid/cancel.gif" 

                                            CommandName="Delete" ConfirmText="Are you sure you want to delete the selected row?">




                                 <ClientSettings AllowRowsDragDrop="True" >

                                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="true"/>

                                    <ClientEvents OnRowSelected="RowSelected" />



Open in new window

Question by:Plecoman
    LVL 3

    Accepted Solution

    hi,  I am not very clear with the question... but i think the following code will solve out your problems...
    Use the <rad:GridTemplateColumn> . U will get your problem resolved.
    <script language="javascript" type="text/javascript">
            function funcSendTableID(idvalue)
                alert("I am sending the table value " + idvalue + " as it can also be your row number");

    <rad:RadGrid ID="RadGrid1" runat="server" DataSourceID="SqlDataSource1" GridLines="None">
                <MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource1" PageSize="1" AllowPaging="True" DataKeyNames="Tableid">
                    <RowIndicatorColumn Visible="False">
                        <HeaderStyle Width="20px" />
                    <ExpandCollapseColumn Resizable="False" Visible="False">
                        <HeaderStyle Width="20px" />
                        <rad:GridBoundColumn DataField="Tableid" DataType="System.Int32" HeaderText="Tableid"
                            ReadOnly="True" SortExpression="Tableid" UniqueName="Tableid">
                        <rad:GridBoundColumn DataField="TypeOfResource" HeaderText="TypeOfResource" SortExpression="TypeOfResource"
                        <%# DataBinder.Eval(Container.DataItem, "Tableid")%>
                            <div id='<%# DataBinder.Eval(Container.DataItem, "Tableid")%>' onclick="funcSendTableID(">
                             Send the Row Number as Table ID
                    <PagerStyle Mode="NextPrevAndNumeric" />

    Author Closing Comment

    Thank you for your help

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    Great sound, comfort and fit, excellent build quality, versatility, compatibility. These are just some of the many reasons for choosing a headset from Sennheiser.
    Local Continuous Replication is a cost effective and quick way of backing up Exchange server data. The following article describes the steps required to configure Local Continuous Replication. Also, the article tells you how to restore from a backup…
    Internet Business Fax to Email Made Easy - With eFax Corporate (, you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now