Truong Giang Thai
Top achievements
Rank 1
Truong Giang Thai
asked on 09 Nov 2009, 10:02 AM
I used RadGird1.Items.Count and RadGird1.MasterTableView.Items.Count, but both aren't successful. I don't know how to do?
3 Answers, 1 is accepted
0
Truong Giang Thai
Top achievements
Rank 1
answered on 09 Nov 2009, 10:24 AM
| protected void _gridIssues_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e) |
| { |
| IssueFactory factory = new IssueFactory(Global.RepositoryFactory); |
| List<Issue> issues = new List<Issue>(); |
| issues = factory.RetrieveIssues(bShowHandledOnly, bShowSubmittedOnly, bShowClosed, new Identity(CurrentUserID)); |
| if (CustomerLastUpdated) |
| { |
| issues = (from i in issues |
| where i.LastUpdatedByPerformer == true |
| select i).ToList<Issue>(); |
| } |
| _gridIssues.DataSource = issues; |
| _gridIssues.VirtualItemCount = _gridIssues.MasterTableView.Items.Count; |
| } |
| <telerik:RadGrid |
| ID="_gridIssues" runat="server" Theme="Default" |
| AllowPaging="true" |
| AllowSorting="true" |
| AllowCustomPaging="True" |
| EnableTheming="false" |
| PagerStyle-AlwaysVisible="true" |
| AutoGenerateColumns="False" EnableAJAX="True" |
| Skin="Office2007" |
| GridLines="None" |
| Width="100%" |
| OnNeedDataSource="_gridIssues_NeedDataSource" |
| OnItemCreated="_gridIssues_ItemCreated" |
| > |
| <%--ShowGroupPanel="true"--%> |
| <MasterTableView EditMode="InPlace"> |
| <PagerTemplate> |
| <asp:Panel ID="PagerPanel" Style="padding: 6px; line-height: 24px" runat="server"> |
| <div style="float: left"> |
| <span style="margin-right: 3px;">Page size:</span> |
| <telerik:RadComboBox ID="RadComboBox1" DataSource="<%# new object[]{10, 20, 30, 40, 50} %>" |
| Style="margin-right: 20px;" Width="50px" SelectedValue='<%# DataBinder.Eval(Container, "Paging.PageSize") %>' |
| runat="server" OnClientSelectedIndexChanged="RadComboBox1_SelectedIndexChanged"> |
| </telerik:RadComboBox> |
| </div> |
| <asp:Panel runat="server" ID="NumericPagerPlaceHolder" /> |
| </asp:Panel> |
| </PagerTemplate> |
| <PagerStyle Mode="NumericPages" PageButtonCount="10" /> |
| <RowIndicatorColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </RowIndicatorColumn> |
| <ExpandCollapseColumn> |
| <HeaderStyle Width="20px"></HeaderStyle> |
| </ExpandCollapseColumn> |
| <Columns> |
| <telerik:GridTemplateColumn HeaderText="ID"> |
| <ItemTemplate> |
| <asp:HyperLink ID="_hplId" runat="server" Text='<%# Eval("ID.DisplayableID") %>' NavigateUrl='<%# Eval("ID.DisplayableID", "ViewIssue.aspx?IssueID={0}") %>'></asp:HyperLink> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Customer"> |
| <ItemTemplate> |
| <asp:Label ID="_customerName" runat="server" EnableViewState="False"> <%# HelpDesk.Business.Users.UserFactory.GetDisplayableName((Common.Business.Repository.Identity)Eval("UserID"))%></asp:Label> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Issue"> |
| <ItemTemplate> |
| <asp:HyperLink ID="_hplSubject" runat="server" Text='<%# HelpDesk.Business.BusinessLayer.IssueFactory.ShowIssueSynopsis(Eval("Subject").ToString(),Eval("Body").ToString(),80) %>' NavigateUrl='<%# Eval("ID.DisplayableID", "ViewIssue.aspx?IssueID={0}") %>'></asp:HyperLink> |
| <%# ((Common.Business.Repository.Identity)Eval("StatusID")).IntID.Value==1 ? "<img src=\"images/new.gif\" />" : "" %> |
| <%# (bool)Eval("UpdatedByPerformer") ? "<img src=\"images/updated.gif\" />" : "" %> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Priority"> |
| <ItemTemplate> |
| <asp:Label ID="_lblPriority" runat="server" ForeColor='<%# HelpDesk.HDPage.GetColorByPriority((HelpDesk.Types.IssuePriority)Convert.ToInt64(Eval("Priority"))) %>' EnableViewState="False"><%# ((HelpDesk.Types.IssuePriority)Convert.ToInt64(Eval("Priority"))).ToString() %></asp:Label> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridBoundColumn DataField="Status" HeaderText="Status"> |
| <ItemStyle Wrap="false" /> |
| </telerik:GridBoundColumn> |
| <telerik:GridTemplateColumn HeaderText="Category"> |
| <ItemTemplate> |
| <%# Eval("Section").ToString().Length == 0 ? "" : (Eval("Section") + " / ") %> |
| <%# Eval("Category") %> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| <telerik:GridTemplateColumn HeaderText="Last Customer Update"> |
| <ItemTemplate> |
| <asp:Label ID="_lblAge" runat="server" Text='<%# HelpDesk.Business.BusinessLayer.IssueFactory.GetAge(Eval("LastCustomerUpdateDate")) %>'></asp:Label> |
| </ItemTemplate> |
| </telerik:GridTemplateColumn> |
| </Columns> |
| </MasterTableView> |
| <ClientSettings AllowDragToGroup="true" /> |
| </telerik:RadGrid> |
No problem if i set VirtualItemCount = 200, but i want its value is total record of RadGird. Any one help me?
0
Truong Giang Thai
Top achievements
Rank 1
answered on 10 Nov 2009, 04:05 AM
I can't find out the topic which have similar content. I think it's easy to do but i'm a new member of control telerik. Any one help me resolve this problem.
0
Hi Truong,
The Items collection of RadGrid contains only the rows displayed on the current grid page. Therefore, if you need to total number of rows, you should get them either directly from your data-access layer or set AllowPaging=false, rebind the grid, get the RadGrid1.Items.Count number, set back AllowPaging=true, and rebind the grid again.
Best wishes,
Tsvetoslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
The Items collection of RadGrid contains only the rows displayed on the current grid page. Therefore, if you need to total number of rows, you should get them either directly from your data-access layer or set AllowPaging=false, rebind the grid, get the RadGrid1.Items.Count number, set back AllowPaging=true, and rebind the grid again.
Best wishes,
Tsvetoslav
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.