This is a migrated thread and some comments may be shown as answers.

SelectedItems.Count always 0

2 Answers 111 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Debbie
Top achievements
Rank 1
Debbie asked on 17 Sep 2008, 08:38 PM

I am using a RadGrid that is bound to an objectdatasource. There is no special databinding.  I have a GridClientSelectColumn and turend on AllowRowSelect = true, and AllowMultirowSelect = true

I have a button on the page that attempts to loop thru the selectedItems of the gird, but the SelecteItems.Count is always ZERO.  Why?

<telerik:RadGrid Visible="true" runat="Server" ID="gridTest" 
                AllowSorting="True" Skin="Web20"   
 
                DataSourceID="odsAcceptedOpenItems" GridLines="None" Width="98%" AutoGenerateColumns="false" 
 
                AllowMultiRowSelection="true" EnableViewState="true">  
 
                 
 
                <ClientSettings EnableRowHoverStyle="True" EnablePostBackOnRowClick="true">  
 
                    <Scrolling AllowScroll="True" UseStaticHeaders="True" /> 
 
                    <Selecting AllowRowSelect="True" /> 
 
                </ClientSettings> 
 
                <MasterTableView TableLayout="Fixed" DataKeyNames="Id" Name="Items" GridLines="Horizontal" 
 
                    DataSourceID="odsAcceptedOpenItems">  
 
                    <Columns> 
 
                        <telerik:GridClientSelectColumn HeaderStyle-Width="25px" UniqueName="colSelect" Visible="false" /> 
 
                        <telerik:GridBoundColumn DataField="ProductName" HeaderText="Product" SortExpression="ProductName" /> 
 
                    </Columns> 
 
                </MasterTableView> 
 
            </telerik:RadGrid> 
 

Thanks!
Debbie

2 Answers, 1 is accepted

Sort by
0
Debbie
Top achievements
Rank 1
answered on 17 Sep 2008, 09:29 PM
Additionally, when I try to use the checkbox in the header of the GridClientSelectColumn or use the dragging to select multiple rows (assuming EnableDragToSelectRows = true) -- results in Javascript error.

I'm not sure why this isn't working.

I used the selectedItems collection on  a grid a while ago and it worked with no problems. Never encountered any of these problems. I then tried to copy & paste that grid into a new page,and now that new page has same problems (with seletedItems.count = 0), but the original page still works.

I've compared the two, and can't see what might be the problem.  They look identical.

Any help is appreciated.

thanks!
Debbie
0
Debbie
Top achievements
Rank 1
answered on 18 Sep 2008, 12:21 AM
Nevermind, I found the problem.  

<xhtmlConformance mode="Legacy"/>

When in the Web.Config can cause issues with Ajax.

Here is a helpful article on the web i found.

http://weblogs.asp.net/scottgu/archive/2006/12/10/gotcha-don-t-use-xhtmlconformance-mode-legacy-with-asp-net-ajax.aspx

Thanks!
Debbie

Tags
Grid
Asked by
Debbie
Top achievements
Rank 1
Answers by
Debbie
Top achievements
Rank 1
Share this question
or