TreeList.SelectedItems仅显示telerik中当前页面选定的项目

时间:2018-03-24 14:10:01

标签: asp.net foreach telerik radtreelist

我在这里使用Telerik Radtreelist控件是标记

<telerik:RadTreeList ID="rtreeList_Topic" runat="server" OnNeedDataSource="rtreeList_Topic_NeedDataSource"
                             ParentDataKeyNames="parent_topicid" DataKeyNames="topicid" AllowPaging="true" RenderMode="Classic" Skin="WebBlue"
                             AutoGenerateColumns="false" AllowSorting="true" 
                             OnDeleteCommand="rtreeList_Topic_OnDeleteCommand" OnInsertCommand="rtreeList_Topic_OnInsertCommand" 
                            OnUpdateCommand="rtreeList_Topic_OnUpdateCommand"  AllowMultiItemSelection="True"
                             OnItemDataBound="rtreeList_Topic_OnItemDataBound" HeaderStyle-Height="35px">

            <Columns>
                <telerik:TreeListSelectColumn HeaderStyle-Width="25px">
                </telerik:TreeListSelectColumn>
                <telerik:TreeListTemplateColumn HeaderText="Topic ID" HeaderStyle-Width="40px">
                    <ItemTemplate>
                        <asp:HyperLink ID="targetControl" runat="server" NavigateUrl="#" Text='<%# Eval("topicid") %>'></asp:HyperLink>
                    </ItemTemplate>
                </telerik:TreeListTemplateColumn>
                <telerik:TreeListBoundColumn DataField="parent_topicid" UniqueName="parent_topicid" HeaderText="Parent Topic Id" Visible="False">
                </telerik:TreeListBoundColumn>

在这里,你可以看到我有一个TreeListSelectColumn,在选择之后我想让每个选中 TreeListDataItem ..

由于显而易见的原因,我可以迭代Radtreelistselected项目

foreach(var item in rtreeList_Topic.SelectedItems) 
{
    var dr = dtselected.NewRow();
    dr["parent_topic_id"] = item["parent_topicid"].Text.Contains("&nbsp;") ? DBNull.Value : (object) Convert.ToInt32(item["parent_topicid"].Text);
    dr["subject_code"] = rcb_subject_code.SelectedItem.Text;
    dr["topic_id"] = Convert.ToInt32(item["topicid"].Text);
    dr["topic_description"] = item["topicname"].Text;
    dr["topic_shortname"] = item["ShortName"].Text;
    dtselected.Rows.Add(dr);
}

现在说在第一页(在页脚中你可以有页面)选择了4个项目,在第二页上我选择了2个项目。 所以rtreeList_Topic.SelectedItems.Count = 6?但没有它只显示第二页的选定项目..为什么?如果我的代码中有任何问题,请告诉我..谢谢:)

0 个答案:

没有答案