or
foreach (GridItem item in grid.Items){ RadNumericTextBox txtBox = (RadNumericTextBox)item.FindControl("txtBox"); }| <telerik:RadGrid ID="uxByAgeAndGenderGrid" runat="server" AutoGenerateColumns="false" CssClass="gridAlternatingRows" |
| OnItemDataBound="uxByAgeAndGenderGrid_OnItemDataBound" OnNeedDataSource="uxByAgeAndGenderGrid_OnNeedDataSource"> |
| <MasterTableView GroupLoadMode="Client" ShowGroupFooter="true" HeaderStyle-Font-Bold="true" ShowFooter="true"> |
| <GroupByExpressions> |
| <telerik:GridGroupByExpression> |
| <SelectFields> |
| <telerik:GridGroupByField FieldName="RequestedGender" HeaderText=" " HeaderValueSeparator="" /> |
| </SelectFields> |
| <GroupByFields> |
| <telerik:GridGroupByField FieldName="RequestedGender" /> |
| </GroupByFields> |
| </telerik:GridGroupByExpression> |
| <telerik:GridGroupByExpression> |
| <SelectFields> |
| <telerik:GridGroupByField FieldName="RequestedMinAge" HeaderText=" " HeaderValueSeparator="" /> |
| </SelectFields> |
| <GroupByFields> |
| <telerik:GridGroupByField FieldName="RequestedMinAgeRank" /> |
| </GroupByFields> |
| </telerik:GridGroupByExpression> |
| </GroupByExpressions> |
| <Columns> |
| <telerik:GridBoundColumn DataField="Status" HeaderText="Status" SortExpression="StatusRank"> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="NewCount" HeaderText="New invitations" Aggregate="Sum" FooterText="Total: "> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="ReinviteCount" HeaderText="Re-invite invitations" Aggregate="Sum" FooterText="Total: "> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="AskedForCount" HeaderText="Asked For invitations" Aggregate="Sum" FooterText="Total: "> |
| </telerik:GridBoundColumn> |
| <telerik:GridBoundColumn DataField="TotalCount" HeaderText="Total" Aggregate="Sum" FooterText="Grand total: "> |
| </telerik:GridBoundColumn> |
| </Columns> |
| </MasterTableView> |
| </telerik:RadGrid> |
| GroupsDefaultExpanded="false" |
| if (!IsPostBack) |
| { |
| uxByAgeAndGenderGrid.Rebind(); |
| foreach (GridItem item in uxByAgeAndGenderGrid.MasterTableView.Controls[0].Controls) |
| { |
| if (item is GridGroupHeaderItem) |
| { |
| item.Expanded = false; |
| } |
| } |
| } |
| Server Error in '/' Application. |
| StartIndex cannot be less than zero. |
| Parameter name: startIndex |
| Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. |
| Exception Details: System.ArgumentOutOfRangeException: StartIndex cannot be less than zero. |
| Parameter name: startIndex |
| Source Error: |
| Line 37: if (item is GridGroupHeaderItem) |
| Line 38: { |
| Line 39: item.Expanded = false; |
| Line 40: } |
| Line 41: } |
| Source File: C:\VS\Flive\Main\Source\FliveSolution\Freshair.Flive\Experiences\FriendlyTown\FtByTheNumbers.aspx.cs Line: 39 |
| Stack Trace: |
| [ArgumentOutOfRangeException: StartIndex cannot be less than zero. |
| Parameter name: startIndex] |
| System.String.Remove(Int32 startIndex) +6576122 |
| Telerik.Web.UI.GridGroupHeaderItem.GroupFooterByHeaderIndexAndSequenceNumber(String groupIndex, Int32 seqNum) +202 |
| Telerik.Web.UI.GridGroupHeaderItem.SetVisibleChildren(Boolean value) +794 |
| Telerik.Web.UI.GridItem.set_Expanded(Boolean value) +126 |
| Freshair.Flive.Experiences.FriendlyTown.FtByTheNumbersPage.OnLoad(EventArgs e) in C:\VS\Flive\Main\Source\FliveSolution\Freshair.Flive\Experiences\FriendlyTown\FtByTheNumbers.aspx.cs:39 |
| System.Web.UI.Control.LoadRecursive() +71 |
| System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3048 |
| Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 |
| protected void uxByAgeAndGenderGrid_OnNeedDataSource(Object sender, GridNeedDataSourceEventArgs e) |
| { |
| Int32 programYear = DateTime.Today.GetChildApplicationProgramYear(); |
| var childrenWhoParticipatedInPreviousYears = |
| from child in Ctx.Persons |
| join vep in Ctx.ViewExperienceParticipations on child.PersonId equals vep.PersonId |
| join status in Ctx.ExperienceEligibilityPersonParticipationStatus on vep.CurrentStatusId equals status.ExperienceEligibilityPersonParticipationStatusId |
| join ee in Ctx.ExperienceEligibilities on vep.ExperienceEligibilityId equals ee.ExperienceEligibilityId |
| join exp in Ctx.Experiences on ee.ExperienceId equals exp.ExperienceId |
| join et in Ctx.ExperienceTypes on exp.ExperienceTypeId equals et.ExperienceTypeId |
| where !status.NullifiesParticipation |
| where status.ExperienceEligibilityPersonParticipationStatusId != 1 // Other than Invited |
| where exp.FromDate.Value.Year < programYear |
| select new |
| { |
| child.PersonId, |
| exp.HostingHouseholdId |
| }; |
| List<String> statusRank = new List<String>(); |
| statusRank.Add("Matched"); |
| statusRank.Add("Open"); |
| statusRank.Add("Invited"); |
| statusRank.Add("Placed"); |
| statusRank.Add("Refused"); |
| statusRank.Add("Not Found"); |
| statusRank.Add("Excused"); |
| statusRank.Add("Proposed New Dates"); |
| statusRank.Add("Must Approve Trip Dates"); |
| statusRank.Add("Child proposed new dates"); |
| statusRank.Add("Child must approve dates"); |
| statusRank.Add("Didn't Show"); |
| statusRank.Add("Attended"); |
| statusRank.Add("Returned Early"); |
| statusRank.Add("Transferred Out"); |
| statusRank.Add("Canceled"); |
| statusRank.Add("Closed by child"); |
| statusRank.Add("Withdrawn by host"); |
| statusRank.Add("Change In Progress"); |
| List<String> ageRank = new List<String>(); |
| ageRank.Add("0 to 5"); |
| ageRank.Add("6 to 8"); |
| ageRank.Add("9 to 10"); |
| ageRank.Add("11 to 12"); |
| ageRank.Add("Over 13"); |
| ageRank.Add("Unknown"); |
| DateTime today = DateTime.Today; |
| var invitations = |
| (from exp in Ctx.Experiences |
| join et in Ctx.ExperienceTypes on exp.ExperienceTypeId equals et.ExperienceTypeId |
| join ec in Ctx.ExperienceCategories on et.ExperienceCategoryId equals ec.ExperienceCategoryId |
| join vee in Ctx.ViewActiveEligibilityByExperiences on exp.ExperienceId equals vee.ExperienceId |
| join ee in Ctx.ExperienceEligibilities on vee.ExperienceEligibilityId equals ee.ExperienceEligibilityId |
| join reqPerson in Ctx.Persons on ee.PersonId equals reqPerson.PersonId into reqPersons |
| from reqPerson in reqPersons.DefaultIfEmpty() |
| join part in Ctx.ViewExperienceParticipations on ee.ExperienceEligibilityId equals part.ExperienceEligibilityId into parts |
| from part in parts.DefaultIfEmpty() |
| join person in Ctx.Persons on part.PersonId equals person.PersonId into persons |
| from person in persons.DefaultIfEmpty() |
| join status in Ctx.ExperienceEligibilityPersonParticipationStatus on part.CurrentStatusId equals status.ExperienceEligibilityPersonParticipationStatusId into statuses |
| from status in statuses.DefaultIfEmpty() |
| join searchParam in Ctx.ViewInvitationEligibilityParameters on ee.SearchId equals searchParam.SearchId into searchParams |
| from searchParam in searchParams.DefaultIfEmpty() |
| where exp.FromDate.GetValueOrDefault(new DateTime(1877, 1, 1)).Year == programYear |
| where et.ExperienceCategoryId == 1 |
| where part == null || part.ExperienceEligibilityPersonParticipationTypeId == 1 // Child |
| where person == null || person.PersonId != 30190 |
| select new |
| { |
| RequestedGender = reqPerson == null ? (searchParam == null ? "Unknown" : |
| (searchParam.Gender == null ? "Either a boy or a girl" : |
| (searchParam.Gender == "M" ? "Only a boy" : "Only a girl"))) : |
| (reqPerson.Gender == null ? "Unknown" : (reqPerson.Gender == "M" ? "Only a boy" : "Only a girl")), |
| RequestedMinAge = reqPerson == null ? (searchParam == null ? -1 : |
| (searchParam.MinAge == null ? -1 : searchParam.MinAge)) : |
| (reqPerson.BirthDate == null ? -1 : Ctx.FuncGetAge(reqPerson.BirthDate, today)), |
| IsNew = ee.SearchId != null ? true : false, |
| IsReinvite = ee.PersonId == null ? false : |
| (childrenWhoParticipatedInPreviousYears.Where(p => p.PersonId == ee.PersonId && p.HostingHouseholdId == exp.HostingHouseholdId).Count() > 0 ? true : false), |
| Program = ec.Name, |
| StatusId = status == null ? 0 : status.ExperienceEligibilityPersonParticipationStatusId, |
| IsWithdrawn = exp.IsCanceled |
| }).ToArray(); |
| var invitations2 = |
| (from invitation in invitations |
| group new |
| { |
| IsNew = invitation.IsNew, |
| IsReinvite = invitation.IsReinvite |
| } by new |
| { |
| RequestedGender = invitation.RequestedGender, |
| RequestedMinAge = invitation.RequestedMinAge < 0 ? "Unknown" : |
| (invitation.RequestedMinAge < 6 ? "0 to 5" : |
| (invitation.RequestedMinAge < 9 ? "6 to 8" : |
| (invitation.RequestedMinAge < 11 ? "9 to 10" : |
| (invitation.RequestedMinAge < 13 ? "11 to 12" : "Over 13")))), |
| Status = invitation.IsWithdrawn ? "Withdrawn by host" : FtLogicController.GetInvitationStatusByCurrentParticipationStatus(invitation.StatusId).GetStatusText() |
| } into grouping |
| select grouping).ToArray(); |
| var invitationsToBind = |
| from grouping in invitations2 |
| select new |
| { |
| RequestedGender = grouping.Key.RequestedGender, |
| RequestedMinAge = grouping.Key.RequestedMinAge, |
| RequestedMinAgeRank = ageRank.IndexOf(grouping.Key.RequestedMinAge), |
| Status = grouping.Key.Status, |
| StatusRank = statusRank.IndexOf(grouping.Key.Status), |
| NewCount = grouping.Count(p => p.IsNew), |
| ReinviteCount = grouping.Count(p => p.IsReinvite), |
| AskedForCount = grouping.Count(p => !p.IsReinvite && !p.IsNew), |
| TotalCount = grouping.Count() |
| }; |
| uxByAgeAndGenderGrid.GroupingSettings.RetainGroupFootersVisibility = true; |
| uxByAgeAndGenderGrid.DataSource = invitationsToBind.OrderBy(p => p.StatusRank); |
| uxInvitationsToBeFilled.Text = invitationsToBind.Where(p => p.Status == "Open").Sum(p => p.TotalCount).ToString(); |
| uxMatchedInvitationsNotYetDeparted.Text = invitationsToBind.Where(p => p.Status == "Matched").Sum(p => p.TotalCount).ToString(); |
| } |
<body> <form id="form1" runat="server"> <telerik:RadScriptManager ID="RadScriptManager1" runat="server"> <Scripts> <%--Needed for JavaScript IntelliSense in VS2010--%> <%--For VS2008 replace RadScriptManager with ScriptManager--%> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" /> <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" /> </Scripts> </telerik:RadScriptManager> <script type="text/javascript"> //Put your JavaScript code here. function keyDown(e) { if (e.keyCode == 13) { //get text box client id to check if it's not empty var tbCliendId = document.getElementById("tbId").value; var tb = document.getElementById(tbCliendId); if (tb.value.length > 0) { //get "Go" button client ID from the hidden field value var buttonCliendId = document.getElementById("goLinkId").value; var button = document.getElementById(buttonCliendId); button.click(); } } } </script> <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> </telerik:RadAjaxManager> <div> <asp:HiddenField ID="tbId" runat="server" /> <asp:HiddenField ID="goLinkId" runat="server" /> <telerik:RadGrid ID="RadGrid1" runat="server" AllowPaging="true" PageSize="2" OnNeedDataSource="RadGrid1_NeedDataSource" OnItemCreated="RadGrid1_ItemCreated"> <PagerStyle Mode="NextPrevNumericAndAdvanced" AlwaysVisible="true" /> <MasterTableView> <Columns> <telerik:GridBoundColumn HeaderText="Vendor" DataField="Vendor"> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="Address" DataField="Address"> </telerik:GridBoundColumn> <telerik:GridBoundColumn HeaderText="Bank" DataField="Bank"> </telerik:GridBoundColumn> </Columns> </MasterTableView> </telerik:RadGrid> </div> </form></body>protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e){ DataTable dt = new DataTable(); dt.Columns.Add("Vendor"); dt.Columns.Add("Address"); dt.Columns.Add("Bank"); dt.Rows.Add("ABC1", "Address1", "Bank1"); dt.Rows.Add("ABC2", "Address2", "Bank2"); dt.Rows.Add("ABC3", "Address3", "Bank3"); dt.Rows.Add("ABC4", "Address4", "Bank4"); dt.Rows.Add("ABC5", "Address5", "Bank5"); dt.Rows.Add("ABC6", "Address6", "Bank6"); RadGrid1.DataSource = dt;}protected void RadGrid1_ItemCreated(object sender, GridItemEventArgs e){ if (e.Item is GridPagerItem) { //find the text box RadNumericTextBox pageNum = (RadNumericTextBox)e.Item.FindControl("GoToPageTextBox"); tbId.Value = pageNum.ClientID; //find 'Go' link button Button goLink = (Button)e.Item.FindControl("GoToPageLinkButton"); goLinkId.Value = goLink.ClientID; //attach to onkeydown event pageNum.Attributes.Add("onkeydown", "keyDown(event);"); }}<telerik:RadListView ID="RadGrid_Bookmarks" runat="server" OnNeedDataSource="RadGrid_Bookmarks_NeedDataSource" EnableViewState="true" ItemPlaceholderID="phRadListView" > <LayoutTemplate> <telerik:RadDataPager ID="radPager1" runat="server" Skin="Windows7" OnPreRender="radPager_PreRender" OnInit="radPager_Init" > <Fields> <telerik:RadDataPagerTemplatePageField HorizontalPosition="LeftFloat"> <PagerTemplate> <div style="float: right;color:#666666;"> Displaying items <asp:Label runat="server" ID="PageItemFromLabel" /> to <asp:Label runat="server" ID="PageItemToLabel" /> of <asp:Label runat="server" ID="TotalItemsLabel" /> </div> </PagerTemplate> </telerik:RadDataPagerTemplatePageField> <telerik:RadDataPagerButtonField FieldType="NextLast" HorizontalPosition="RightFloat" /> <telerik:RadDataPagerButtonField FieldType="Numeric" HorizontalPosition="RightFloat" /> <telerik:RadDataPagerButtonField FieldType="FirstPrev" HorizontalPosition="RightFloat" /> </Fields> </telerik:RadDataPager>protected void ddlDays_SelectedIndexChanged(object sender, EventArgs e) { RadGrid_Bookmarks.Rebind(); } protected void RadGrid_Bookmarks_NeedDataSource(object source, RadListViewNeedDataSourceEventArgs e) { DataSet dsBookmarks = GetPostsByUser(UserID, uID, SiteID, int.Parse(ddlDays.SelectedValue), RadGrid_Bookmarks.CurrentPageIndex + 1); RadGrid_Bookmarks.VirtualItemCount = int.Parse(dsBookmarks.Tables[0].Rows[0]["totalRec"].ToString()); RadGrid_Bookmarks.PageSize = 50; RadGrid_Bookmarks.DataSource = dsBookmarks.Tables[1]; } protected void radPager_PreRender(object sender, EventArgs e) { RadDataPager rdp = (RadDataPager)sender; ((Label)rdp.Controls[0].FindControl("PageItemFromLabel")).Text = (rdp.StartRowIndex + 1).ToString(); ((Label)rdp.Controls[0].FindControl("PageItemToLabel")).Text = ((rdp.TotalRowCount < (rdp.StartRowIndex + rdp.PageSize)) ? rdp.TotalRowCount : rdp.StartRowIndex + rdp.PageSize).ToString(); ((Label)rdp.Controls[0].FindControl("TotalItemsLabel")).Text = rdp.TotalRowCount.ToString(); if (rdp.TotalRowCount <= rdp.PageSize) rdp.Visible = false; } protected void radPager_Init(object sender,EventArgs e) { RadDataPager rdp = (RadDataPager)sender; rdp.PageSize = 50; }