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>
<telerik:RadGrid ID="RadGrid1" runat="server" PageSize="20" AllowSorting="True" AllowPaging="True" ShowGroupPanel="True" OnColumnCreated="RadGrid1_ColumnCreated"> <PagerStyle Mode="NumericPages"></PagerStyle> <MasterTableView Width="100%"> </MasterTableView> <ClientSettings> <Resizing AllowColumnResize="True"></Resizing> </ClientSettings> </telerik:RadGrid>protected void Button1_Click(object sender, EventArgs e){ string groupBY = "CruiseLine [CruiseLine], Sum(Sales) GroupTotal [CruiseLine Total] Group By CruiseLine"; group(groupBY);}protected void Button2_Click(object sender, EventArgs e){ string groupBY = "Ship [Ship], Sum(Sales) GroupTotal [Ship Total] Group By Ship"; group(groupBY);}protected void Button3_Click(object sender, EventArgs e){ string groupBY = "Date [Date], Sum(Sales) GroupTotal [Date Total] Group By Date"; group(groupBY);}protected void group(string groupBY) { try { GridGroupByExpression expression1 = GridGroupByExpression.Parse(groupBY); this.CustomizeExpression(expression1); this.RadGrid1.MasterTableView.GroupByExpressions.Add(expression1); } catch (Exception ex) { lblError.Text = string.Format("<span style='color:red'>Cannot add group by expression: {0}</span>", ex.Message); lblError.Visible = true; } finally { BindData(); } }protected void BindData() { Hashtable htParams = new Hashtable(); htParams.Add("@CruiseLine", ViewState["prmCruiseLine"]); htParams.Add("@Ship", ViewState["prmShip"]); htParams.Add("@FromDate", FromDate.SelectedDate.Value.ToShortDateString()); htParams.Add("@ToDate", ToDate.SelectedDate.Value.ToShortDateString()); // Call SPROC to populate grid DataUtiliities data = new DataUtiliities("PrepaidConnectionString"); DataSet dsRpt = data.ExecuteDataSet("SelectProductInfoByShipAndDate2", htParams); // Bind the Grid RadGrid1.DataSource = dsRpt.Tables[0].DefaultView; RadGrid1.DataBind(); }groupBY = "CruiseLine [CruiseLine], Sum(Sales) GroupTotal [CruiseLine Total] Group By CruiseLine"expression1 = {CruiseLine , sum(Sales) GroupTotal Group By CruiseLine}groupBY = "Ship [Ship], Sum(Sales) GroupTotal [Ship Total] Group By Ship"expression1 = {Ship , sum(Sales) GroupTotal Group By Ship}Protected Sub grdListeCommande_RowDrop(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDragDropEventArgs) Handles grdListeCommande.RowDrop Dim RowDragged As GridDataItem Dim RowIndexDestin As Integer Dim intChfNRI As Integer Dim intAtcNRI As Integer Dim tabstrip As RadTabStrip Dim grille As RadGrid = Nothing For Each item As GridNestedViewItem In grdChauffeurs.MasterTableView.GetItems(GridItemType.NestedView) tabstrip = item.FindControl("RadTabStrip2") grille = tabstrip.MultiPage.FindControl("grdOrdre") Next RowDragged = e.DraggedItems.FirstOrDefault() If (e.DestDataItem IsNot Nothing) Then If (e.DestDataItem.OwnerGridID = grdChauffeurs.ClientID) Then Me.RowIndex = e.DestDataItem.ItemIndex intAtcNRI = CInt(RowDragged("ATCNRI").Text) intChfNRI = Me.DataTableChauffeur.Rows(Me.RowIndex).Item("NRI") End If Select Case False Case intChfNRI <> Nothing Case intAtcNRI <> Nothing Case pfblnGetRoadSheet(intChfNRI, intAtcNRI) Case Else e.DestDataItem.Expanded = False e.DestDataItem.Expanded = True grille.DataSource = Me.DataTableMouvement End Select End If End Sub<telerik:ResourceType ForeignKeyField="id" KeyField="id" Name="Commands" TextField="CommandName" /> </ResourceTypes>protected void RadScheduler1_FormCreated(object sender, SchedulerFormCreatedEventArgs e) { if ((e.Container.Mode == SchedulerFormMode.AdvancedEdit) || (e.Container.Mode == SchedulerFormMode.AdvancedInsert)) { RadComboBox ddlCommands = (RadComboBox)e.Container.FindControl("ResCommands"); if (ddlCommands != null) { int assetID = int.Parse(Request.QueryString["id"]); string portal = (string)Session["Portal"]; AssetFactory assetFactory = new AssetFactory(portal); ddlCommands.DataSource = CommandEnums.GetListItems(assetFactory.GetAssetType(assetID)); ddlCommands.DataTextField = "Text"; ddlCommands.DataValueField = "Value"; ddlCommands.DataBind(); }}Thread information:
Thread ID: 12
...
Is impersonating: False
Stack trace: at System.Convert.FromBase64String(String s)
at System.Web.UI.ObjectStateFormatter.Deserialize(String inputString)
at System.Web.UI.LosFormatter.Deserialize(String input)
at Telerik.Web.UI.LosSerializer.Deserialize(String serializedObject, Boolean enableMacValidation)
at Telerik.Web.UI.LosSerializer.Deserialize(String serializedObject)
at Telerik.Web.UI.AdvancedTemplate.ExtractResourceValues(IDictionary target)
at Telerik.Web.UI.AdvancedTemplate.ExtractValues(Control container)
at Telerik.Web.UI.RadScheduler.UpdateAppointmentInline(Boolean removeExceptions)
at Telerik.Web.UI.RadScheduler.OnBubbleEvent(Object source, EventArgs args)
at System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args)
at System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e)
at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument)
at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument)
at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
<telerik:RadScheduler ID="RadScheduler1" runat="server" DataEndField="End" DataKeyField="ID" DataRecurrenceField="RecurrenceRule" DataRecurrenceParentKeyField="RecurrenceParentID" DataSourceID="SchedulerDataSource" DataDescriptionField="Description" Height="700px" OnAppointmentCommand="RadScheduler1_AppointmentCommand" StartInsertingInAdvancedForm="true" Reminders-Enabled="true" DataReminderField="Reminder" StartEditingInAdvancedForm="true" OnFormCreated="RadScheduler1_FormCreated" AdvancedForm-EnableCustomAttributeEditing="true" OnAppointmentInsert="RadScheduler1_Scheduled_EventsInsert" OnAppointmentUpdate="RadScheduler1_Scheduled_EventsUpdate" CustomAttributeNames="Parameters" DataStartField="Start" DataSubjectField="Subject" Skin="Sitefinity"> <Localization AdvancedEditAppointment="Edit Event" AdvancedNewAppointment="New Event" /> <AppointmentContextMenuSettings EnableDefault="true" /> <AdvancedForm Modal="true" /> <AppointmentTemplate> <%# Eval("Subject") %> <p style="font-style: italic;"> <%# Eval("Parameters")%></p> </AppointmentTemplate> <TimelineView UserSelectable="false" /> <ResourceTypes> <telerik:ResourceType ForeignKeyField="id" KeyField="id" Name="Commands" TextField="CommandName" /> </ResourceTypes> <ResourceStyles> </ResourceStyles> </telerik:RadScheduler> <asp:SqlDataSource ID="SchedulerDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:ConfigurationConnectionString %>" DeleteCommand="DELETE FROM [Scheduled_Events] WHERE [ID] = @ID" InsertCommand="INSERT INTO [Scheduled_Events] ([Subject], [Start], [End], [RecurrenceRule], [RecurrenceParentID], [Description], [Reminder], [Parameters], [CommandName]) VALUES (@Subject, @Start, @End, @RecurrenceRule, @RecurrenceParentID, @Description, @Reminder, @Parameters, @CommandName)" SelectCommand="SELECT [ID], [Subject], [Start], [End], [RecurrenceRule], [RecurrenceParentID], [Description], [Reminder], [Parameters] FROM [Scheduled_Events]" UpdateCommand="UPDATE [Scheduled_Events] SET [Subject] = @Subject, [Start] = @Start, [End] = @End, [RecurrenceRule] = @RecurrenceRule, [RecurrenceParentID] = @RecurrenceParentID, [Description] = @Description, [Reminder] = @Reminder, [Parameters] = @Parameters, [CommandName] = @CommandName WHERE [ID] = @ID"> <DeleteParameters> <asp:Parameter Name="ID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="Subject" Type="String" /> <asp:Parameter Name="Start" Type="DateTime" /> <asp:Parameter Name="End" Type="DateTime" /> <asp:Parameter Name="RecurrenceRule" Type="String" /> <asp:Parameter Name="RecurrenceParentID" Type="Int32" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Reminder" Type="String" /> <asp:Parameter Name="Parameters" Type="String" /> <asp:Parameter Name="ID" Type="Int32" /> <asp:Parameter Name="CommandName" Type="String" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="Subject" Type="String" /> <asp:Parameter Name="Start" Type="DateTime" /> <asp:Parameter Name="End" Type="DateTime" /> <asp:Parameter Name="RecurrenceRule" Type="String" /> <asp:Parameter Name="RecurrenceParentID" Type="Int32" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Reminder" Type="String" /> <asp:Parameter Name="Parameters" Type="String" /> <asp:Parameter Name="CommandName" Type="String" /> </InsertParameters>
Hello,
Im using the Grid control from Telerik's RadControls. The grid is populated with thousands of records and lists 50 records per page. I have some filtering options appearing above and the solution is in ASP.NET 3.5 with NHibernate 2.1.
Everything works fine and dandy except for when i select one of the bottom rows and some weird onfocus-event occurrs. When a search/listing has been occurred and the focus is on, lets say the search button. I then select one of the bottom rows between record 40-50, and the browser immediately scrolls down an inch or two. But when the focus is on one of the rows within the grid table, i no longer have these strange scrollings. But if i just switch the focus on anything outside the grid, the scrolling bug appears again.
This appears in IE and Chrome, but not Firefox. I guess its some onfocus event that fires when putting the radgrid in focus, but i cant find any solution on how to fix it.
Please help me, its very annoying!
Best regards, Mattias
RadTreeNode node = new RadTreeNode(usedName + " [" + rs.ToString() + "]", "SECTION_" + rs.ToString()); // just some name and valuenode.NodeTemplate = new AdminFunctionsPhenoTreeTemplate(); // makes buttonsnode.ExpandMode = TreeNodeExpandMode.ServerSideCallBack; PhenoTree.Nodes.Add(node); // adding node to RadTree.// selections.RadioButtonList rbRights = (RadioButtonList)node.FindControl("rbRights");if (rbRights != null){ setAccessLevelToRB(rbRights, accessLevel); // set correct radio button using rbRights.SelectedIndex
}node.DataBind();List<RadTreeNode> alls = (List<RadTreeNode>)PhenoTree.GetAllNodes(); foreach (RadTreeNode node in alls) { RadioButtonList rbRights = (RadioButtonList)node.FindControl("rbRights"); accessLevel = getAccessLevelFromRB(rbRights); // this routine simply examines rbRights.SelectedIndex}class AdminFunctionsPhenoTreeTemplate : ITemplate { public void InstantiateIn(Control container) { container.Controls.Add(new LiteralControl("<table style=\"margin:0px;padding:0px;\"><tr><td>")); Label label1 = new Label(); label1.ID = "ItemLabel"; label1.Text = "Text"; label1.Font.Size = 8; // label1.Font.Bold = true; label1.DataBinding += new EventHandler(label1_DataBinding); container.Controls.Add(label1); container.Controls.Add(new LiteralControl("</td><td>")); RadioButtonList rbRights = new RadioButtonList(); rbRights.ID = "rbRights"; rbRights.Items.Add(new ListItem("r/o")); rbRights.Items.Add(new ListItem("r/w")); rbRights.Items.Add(new ListItem("r/w/meta")); rbRights.SelectedIndex = 0; rbRights.RepeatDirection = RepeatDirection.Horizontal; container.Controls.Add(rbRights); container.Controls.Add(new LiteralControl("</td></tr></table>")); } private void label1_DataBinding(object sender, EventArgs e) { Label target = (Label)sender; RadTreeNode node = (RadTreeNode)target.BindingContainer; string nodeText = (string)DataBinder.Eval(node, "Text"); target.Text = nodeText; } }