This was working and somehow I broke it without knowing it. I populate a grid from the database. In the code behind I select some of the Items in the grid (I have a checkbox in the grid item). Should be easy.
However when I try to loop through the items in the table the count on the MasterTableView.Items is 0. But when the page displayed the grid has items.
Here's the code (I removed some non-essential pieces):
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) If Not IsPostBack Then BindScans(Session("ClientID")) Dim ScanGroupID As String = Request("ScanGroupID") & "" If ScanGroupID <> "" Then LoadScanGroup(ScanGroupID) End IfEnd SubSub BindScans(ByVal ClientID As String) Dim sqlConn As SqlConnection = New SqlConnection(Session("SCAN_CONN")) Dim SQL As String = "Select * From nxp_sites SITES WHERE ....." Dim adapter As SqlDataAdapter = New SqlDataAdapter(SQL, sqlConn) Dim dt As DataTable = New DataTable adapter.Fill(dt) rgScans.DataSource = dtEnd SubSub LoadScanGroup(ByVal ScanGroupID As String) Dim oScanGroup As clsScanGroup = New clsScanGroup(ScanGroupID) If Not oScanGroup.HasError Then Dim dt As DataTable = oScanGroup.GetScans() SelectScanGroupItems(dt) End IfEnd SubSub SelectScanGroupItems(ByVal dt As DataTable) If dt.Rows.Count > 0 Then For Each dr As DataRow In dt.Rows 'At this point rgscan.MasterTableView.Items count is 0, why? For Each gdi As GridDataItem In rgScans.MasterTableView.Items If gdi("scan_id").Text = dr("ScanID") And gdi("site_id").Text = dr("SiteID") Then Dim chk As CheckBox = DirectCast(gdi("CheckboxSelectColumn").Controls(0), CheckBox) gdi.Selected = True End If Next Next End IfEnd Sub<telerik:RadGrid ID="rgScans" runat="server" ShowGroupPanel="False" AllowPaging="true" Width="700" AllowMultiRowSelection="true" PageSize="25" Skin="Office2010Silver" AllowSorting="true" AutoGenerateColumns="false" OnNeedDataSource="rgScans_NeedDataSource" > <MasterTableView AutoGenerateColumns="false" DataKeyNames="site_id" InsertItemPageIndexAction="ShowItemOnCurrentPage"> <Columns> <telerik:GridClientSelectColumn UniqueName="CheckboxSelectColumn" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" FooterText="CheckBoxSelect footer" ItemStyle-Width="40px" HeaderStyle-Width="40px"> </telerik:GridClientSelectColumn> <telerik:GridTemplateColumn HeaderText="Current" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="40px" HeaderStyle-Width="40px"> <ItemTemplate> <asp:image imageurl='<%# GetCurrentScan(Eval("site_id"))%>' runat="server" /> </ItemTemplate> </telerik:GridTemplateColumn> <telerik:GridBoundColumn DataField="site_name" ItemStyle-Width="250px" HeaderStyle-Width="250px" FilterControlAltText="Filter ScanGroupName column" HeaderText="Scan Name" AllowFiltering="false" SortExpression="ScanGroupName" UniqueName="ScanGroupName" AllowSorting="true" /> <telerik:GridBoundColumn DataField="start_time" HeaderText="Scan Date/Time" DataFormatString="{0:MM/dd/yyyy}" FilterControlAltText="Filter start_time column" AllowFiltering="false" SortExpression="start_time" UniqueName="start_time" AllowSorting="true" /> <telerik:GridBoundColumn DataField="live_hosts" ItemStyle-Width="100px" HeaderStyle-Width="100px" FilterControlAltText="Filter ScanGroupName column" HeaderText="Live Hosts" AllowFiltering="false" SortExpression="live_hosts" UniqueName="live_hosts" AllowSorting="true" /> <telerik:GridBoundColumn DataField="site_id" ItemStyle-Width="100px" HeaderStyle-Width="100px" FilterControlAltText="Filter ScanGroupName column" HeaderText="Site ID" Visible="false" AllowFiltering="false" SortExpression="site_id" UniqueName="site_id" AllowSorting="true" /> <telerik:GridBoundColumn DataField="scan_id" ItemStyle-Width="100px" HeaderStyle-Width="100px" FilterControlAltText="Filter scan_id column" HeaderText="Scan ID" Visible="false" AllowFiltering="false" SortExpression="scan_id" UniqueName="scan_id" AllowSorting="true" /> </Columns> </MasterTableView> <ClientSettings> <Selecting AllowRowSelect="true"></Selecting> </ClientSettings></telerik:RadGrid>Thank you in advance on this.