我无法在标签中显示值

本文关键字:显示 标签 | 更新日期: 2023-09-27 18:35:41

此函数中的"id"字符串有一个值,但不显示在标签中。我在那里有一个断点,我可以清楚地看到这样的价值。

protected void RadTreeList1_ItemCommand(object sender, TreeListCommandEventArgs e)
{
    string id = "";
    if (e.CommandName == "Select")
    {
        if (e.Item is TreeListDataItem)
        {
            TreeListDataItem item = e.Item as TreeListDataItem;
           id = item.GetDataKeyValue("MessageID").ToString();
        }
    }
    Label2.Text = id;
}

更新并且不像这样工作:

....
string id = item.GetDataKeyValue("MessageID").ToString();
Label2.Text = id;

关于可能原因的任何建议?

我无法在标签中显示值

// try this Put  Label2.Text = id; in   if (e.Item is TreeListDataItem)
protected void RadTreeList1_ItemCommand(object sender, TreeListCommandEventArgs e)
{
    string id = "";
    if (e.CommandName == "Select")
    {
        if (e.Item is TreeListDataItem)
        {
            TreeListDataItem item = e.Item as TreeListDataItem;
             id = Convert.ToString(item.GetDataKeyValue("MessageID")) ;
            Label2.Text = id;
        }
    }
}