AspxTreeList节点选择问题

时间:2010-11-03 15:03:50

标签: c# devexpress

我正在尝试获取聚焦节点值,但在c#“treeList.FocusedNode”中始终返回null。然后我尝试了使用“treeList.FindNodeByKeyValue()”按键值获取节点列表的“CustomCallBack”事件。我传递了键值,但它仍然返回null。我该如何解决这个问题?

这是TreeList的aspx代码:

<dxwtl:ASPxTreeList ID="trlGroup" runat="server" AutoGenerateColumns="False" CssFilePath="~/App_Themes/Aqua/{0}/styles.css"
                                    CssPostfix="Aqua" ParentFieldName="TreeParentId" KeyFieldName="Id" ClientInstanceName="treeListItems"
                                    OnCustomCallback="trlGroup_CustomCallback" Visible="False" 
                                    >
                                    <ClientSideEvents FocusedNodeChanged="function(s,e) {
                                        var key = treeListItems.GetFocusedNodeKey();
                                        var isChild = treeListItems.GetNodeState(key);
                                        if(isChild == 'Child')
                                        {
                                            treeListItems.PerformCallback(key);
                                            gridItems.PerformCallback(key);
                                        }
                                        else
                                        {
                                            alert('Sadece en alt seviyeden seçim yapabilirsiniz.!');
                                        }
                    }" EndCallback="function(s,e){
                        if(s.cp_ShowPopup)
                        {
                            pcc_Question.Show();
                        }
                    }" />
                                    <Columns>
                                        <dxwtl:TreeListDataColumn FieldName="TreeParentId" Visible="false" VisibleIndex="0">
                                        </dxwtl:TreeListDataColumn>
                                        <dxwtl:TreeListDataColumn FieldName="ItemGroupCode" Caption="Master Code" VisibleIndex="1">
                                        </dxwtl:TreeListDataColumn>
                                        <dxwtl:TreeListDataColumn FieldName="ItemGroupDesc" Caption="Page Title" VisibleIndex="2" />
                                    </Columns>

和C#代码是这样的:

protected void trlGroup_CustomCallback(object sender, DevExpress.Web.ASPxTreeList.TreeListCustomCallbackEventArgs e)
        {
            string key = e.Argument.ToString();
            TreeListNode treeNode = trlGroup.FindNodeByKeyValue(key);
            Session["ItemGroupDesc"] = treeNode["ItemGroupDesc"].ToString();
            Session["ItemGroupId"] = key;
        }

at“treeNode [”ItemGroupDesc“]。ToString()”。Net抛出NullReferenceException。我查看了trlGroup.Nodes,它是null。

感谢您的帮助。

1 个答案:

答案 0 :(得分:0)

请确保在每次向服务器发出请求时,ASPxTreeList都绑定到其DataSource。这应该允许您解决问题。有关详细信息,请参阅:

Why might paging (sorting, grouping, filtering) not work in the ASPxGridView?