RadGrid, extracting KeyID of a row selected

Posted on 2009-04-23
Medium Priority
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

Accepted Solution

sandip-mishra earned 1000 total points
ID: 24336446
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(this.id)">
                         Send the Row Number as Table ID
                <PagerStyle Mode="NextPrevAndNumeric" />

Author Closing Comment

ID: 31573977
Thank you for your help

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I came across an unsolved Outlook issue and here is my solution.
Social messanging services like WhatsApp and Facebook can help businesses in ways that many owners don't even imagine, giving new opportunities to connect with customers. Discover some of the most innovative things they can do for your company.
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Suggested Courses
Course of the Month15 days, 8 hours left to enroll

850 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