This is a migrated thread and some comments may be shown as answers.

Trouble setting Text property of ComboBox (seems so simple!)

2 Answers 38 Views
ComboBox
This is a migrated thread and some comments may be shown as answers.
Jesse Lawler
Top achievements
Rank 1
Jesse Lawler asked on 13 May 2010, 06:21 PM
Okay, so I've got a ComboBox that contains a RadTreeView, very similar to the Telerik demo.  Neat functionality.  However, when I'm first loading the page, I naturally want to set both the state of the embedded RadTreeView control and the RadComboBox itself.

In the snippet of code pasted below, you can see how I'm doing this.  (This is all from the Code-Behind.)  The name of the RadComboBox is "WebsiteDocumentationParent," and as you can see in the final line, I'm setting it's .Text property value to be the same as the .Text property of the node that's been selected in the embedded RadTreeView.

The code runs fine, no errors are generated.  However, on the browser the default EmptyMessage always displays.  What could be going on to cause this?

                if (reader.Read())
                {
                    WebsiteDocumentationID.Value = Convert.ToString(reader["webdocID"]);
                    WebsiteDocumentationPageTitle.Text = Convert.ToString(reader["webdocPageTitle"]);
                    WebsiteDocumentationFileEditor.Content = Convert.ToString(reader["webdocContent"]);
                    WebsiteDocumentationParentID.Value = parentID = reader["webdocParentID"].ToString();
                    WebsiteDocumentationParent.Text = ""; // by default empty out the Parent name
                    if (parentID != "")
                    {
                        RadTreeView RadTreeView2 = (RadTreeView)WebsiteDocumentationParent.Items[0].FindControl("RadTreeView2");
                        RadTreeNode foundNode = RadTreeView2.FindNodeByValue(parentID);
                        if (foundNode != null)
                        {
                            foundNode.Selected = true;
                        }
                        WebsiteDocumentationParent.Text = foundNode.Text;
                    }

2 Answers, 1 is accepted

Sort by
0
Simon
Telerik team
answered on 14 May 2010, 02:25 PM
Hello Jesse Lawler,

You can avoid this by selecting the only Item of the RadComboBox and use its Text property for the same purpose. In this way you will have a selected Item and because of this, its Text will be shown in the input. Otherwise RCB considers itself 'empty' and shows its Empty Message.

Greetings,
Simon
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Jesse Lawler
Top achievements
Rank 1
answered on 14 May 2010, 07:47 PM
Thanks!  (I knew it was going to be something that'd make me slap myself in the forehead.)
Tags
ComboBox
Asked by
Jesse Lawler
Top achievements
Rank 1
Answers by
Simon
Telerik team
Jesse Lawler
Top achievements
Rank 1
Share this question
or