?
Solved

RadGrid, extracting KeyID of a row selected

Posted on 2009-04-23
2
Medium Priority
?
10,734 Views
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"];
                        alert(CRS);
                    }
 
                            <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">
                                    <Columns>
                                        <telerik:GridBoundColumn  UniqueName="CrsID" datafield="CrsID" Visible="false"></telerik:GridBoundColumn>
                                        <telerik:GridTemplateColumn HeaderStyle-Font-Size="8" HeaderText="Current Student Profile Contents" UniqueName="crsNumber">
                                            <ItemTemplate>
                                               <asp:Label ID="lblCourseNumber" ForeColor="#333333" Font-Names="arial" Font-Size="9"  Text='<%# Databinder.Eval(Container.DataItem,"crsnumber")%>'
                                                Width="225px" runat="server" BorderWidth="0">
                                               </asp:Label>
                                            </ItemTemplate>
                                        </telerik:GridTemplateColumn>
                                        <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="../skins/webblue/grid/cancel.gif" 
                                            CommandName="Delete" ConfirmText="Are you sure you want to delete the selected row?">
                                        </telerik:GridButtonColumn>
                                    </Columns>
                                </MasterTableView>
                                 <ClientSettings AllowRowsDragDrop="True" >
                                    <Selecting AllowRowSelect="True" EnableDragToSelectRows="true"/>
                                    <ClientEvents OnRowSelected="RowSelected" />
                                </ClientSettings>
                           </telerik:RadGrid>

Open in new window

0
Comment
Question by:Plecoman
2 Comments
 
LVL 3

Accepted Solution

by:
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");
        }
 </script>

<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" />
                </RowIndicatorColumn>
                <ExpandCollapseColumn Resizable="False" Visible="False">
                    <HeaderStyle Width="20px" />
                </ExpandCollapseColumn>
                <Columns>
                    <rad:GridBoundColumn DataField="Tableid" DataType="System.Int32" HeaderText="Tableid"
                        ReadOnly="True" SortExpression="Tableid" UniqueName="Tableid">
                    </rad:GridBoundColumn>
                    <rad:GridBoundColumn DataField="TypeOfResource" HeaderText="TypeOfResource" SortExpression="TypeOfResource"
                        UniqueName="TypeOfResource">
                    </rad:GridBoundColumn>
                    <rad:GridTemplateColumn>
                    <ItemTemplate>
                    <%# DataBinder.Eval(Container.DataItem, "Tableid")%>
                        <div id='<%# DataBinder.Eval(Container.DataItem, "Tableid")%>' onclick="funcSendTableID(this.id)">
                         Send the Row Number as Table ID
                        </div>
                    </ItemTemplate>
                    </rad:GridTemplateColumn>
                </Columns>
                <PagerStyle Mode="NextPrevAndNumeric" />
            </MasterTableView>
        </rad:RadGrid>
0
 

Author Closing Comment

by:Plecoman
ID: 31573977
Thank you for your help
0

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